[ Home |
Alpha index |
Topic index |
Tutorials |
Download |
Feedback ]
The OS/2 API Project
DosSubAllocMem
[ Syntax |
Params |
Returns |
Include |
Usage |
Structs |
Gotchas |
Code |
Also ]
Syntax
rc = DosSubAllocMem( pOffset,
pBlockOffset,
ulSize );
Parameters
- PVOID pOffset (input)
- This is the offset of the memory pool from which the memory block is to
be allocated.
- PPVOID pBlockOffset (output)
- This is a pointer to a longword, in which the offset of the allocated
memory block is to be stored.
- ULONG ulSize (input)
- The size, in bytes, of the memory block requested.
Returns
- APIRET rc
- The following values can be returned
-
0 | NO_ERROR |
87 | ERROR_INVALID_PARAMETER |
311 | ERROR_DOSSUB_NOMEM |
532 | ERROR_DOSSUB_CORRUPTED |
Include Info
#define INCL_DOSMEMMGR
#include <os2.h>
#include <bsememf.h>
Usage Explanation
DosSubAllocMem allocates a memory block from a memory pool created using DosSubSetMem.
The size should be a multiple of 8 bytes. If it is not, the system will
round it up. The maximum value is the size of the memory pool initialized
with DosSubSetMem minus 64 bytes.
Relevant Structures
Gotchas
The maximum value is the size of the memory pool initialized with DosSubSetMem minus 64 bytes.
Sample Code
#define INCL_YOURSTUFF
#include
#include
PVOID Offset;
/* Offset to the memory pool from which the */
/* memory is to be allocated. */
PPVOID BlockOffset;
/* Pointer to a variable that will recieve the */
/* offset of the suballocated memory. */
ULONG Size;
/* The requested size in bytes. */
APIRET rc;
/* Just to take care of the return code */
/* Use DosSubSetMem to create a memory pool and set the Offset */
/* variable to the address of this memory pool. */
Size = 57;
/* Rounded up to 64 bytes. */
rc = DosSubAllocMem( Offset, BlockOffset, Size);
/* The BlockOffset variable will now contain the address */
/* of the memory block we have allocated from the */
/* memory pool. */
if (rc != 0)
{
/* We have an error we must take care of. */
}
See Also
DosSubFreeMem,
DosSubUnsetMem,
DosSubSetMem
Author
Stefan Mars -
mars@lysator.liu.se
Additions
Last modified March 16/1996
Please send all errors, comments, and suggestions to:
timur@vnet.ibm.com
The OS/2 API Project |
DosSubAllocMem |