Borland C++ reference

setblock, _dos_setblock

raw OCR

Modifies the size of a previously allocated block.

Defined in header <dos.h>

Syntax

#include <dos.h>
int setblock(unsigned segx, unsigned  newsize);
unsigned  _dos_setblock(unsigned   newsize, unsigned segx,
                          unsigned  *maxp);

setblock and  _dos_setblock  modify  the size of a memory  segment,  segx is
the segment  address returned  by a previous call to allocmem or
_dos_allocmem.    newsize is the new, requested size in paragraphs. If the
sement  cannot be changed  to the new  size, _dos_setblock stores the sizeof
the largest possible segment at the location pointed to by maxp.

Portability

DOSUNIXWindowsANSI CC++ only
■

Return value

setblock returns -1 on success. In the event of error, it returns the size of the largest possible block (in paragraphs), and the global variable _doserrno is set.

_dos_setblock returns 0 on success. In the event of error, it returns the DOS error code, and the global variable errno is set to the following:

ENOMEMNot enough memory, or bad segment address

See also

Example

#include <doS'.h>
#include <alloc.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)  /* Example for setblock. */
{
   unsigned int size, segp;
   int Stat;
   size = 64;               /*  (64 x 16) = 1024 bytes */
   Stat = allocmemlsize, &segp);
   if (Stat == -1)
      printf("Allocated memory at segment: %X\n", segp);
   else {
      printf("Failed: maximum number of paragraphs available  is %d\n", stat);
      exit(l);
   }
   Stat = setblock(segp, size * 2);
   if (stat ■== -1)
      printf( "Expanded mem.ory blo'ckat segment: %X\n", segp);
   else
      printf("Failed: maximum number of paragraphs available  is %d\n", stat);
   freemem(segp);
   return 0;
}

#include <dos.h>
#include <stdio.h>

int main(void)  /* Example for _dos_setblock. */
{
   unsigned int size, segp, err, maxb;
   size = 64; /* (64 x 16) = 1024 bytes */
   err = _dos_allocmem(size, &segp) ;
   if (err == 0)
      printf("Allocated memory at segment: %x\n", segp);
   else {
      perror("Unable to allocate block");
   printf ("Maximum no. of paragraphs available is %u\n", segp)
   return 1;
}
if (_dos_setblock(size * 2, segp, &maxb) ==  0)
   printf("Expanded memory block at segment:  %X\n", segp);
else {
   perror("Unable to expand block");
   printf ("Maximum no. of paragraphs available is %u\n", maxb)
}
_dos_freemem(segp);
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `setblock, dos setblock` read as `setblock, _dos_setblock`