 | C166 User's Guide |  |
|
|
| malloc_b| Summary |
#include <stdlib.h>
void far *malloc_b (
size_t size); /* block size to allocate */
or
void huge *malloc_b (
size_t size); /* block size to allocate */
| | Description | The malloc_b function allocates a memory block from the memory pool of size bytes in length. Note - Source code for this routine is provide in the LIB folder. You may modify the source to customize this function for your particular hardware environment.
- Pointer return values are far in Small, Medium, Compact, and Large Memory Models and huge in HCompact, HLarge, and XLarge Memory Models. This function is not supported in the Tiny Memory Model.
| | Return Value | The malloc_b function returns a pointer to the allocated block or a null pointer if there is not enough memory to satisfy the allocation request. | | See Also | calloc_b, free_b, init_mempool_b, realloc_b | | Example |
#include <stdlib.h>
#include <stdio.h> /* for printf */
void tst_malloc_b (void) {
unsigned char far *p;
p = malloc_b (1000); /* allocate 1000 bytes */
if (p == NULL)
printf ("Not enough memory space\n");
else
printf ("Memory allocated\n");
}
|
|
|