C Programming/MS Windows Reference/alloc.h

"alloc.h" is a non-standard header file. It is not part of the ANSI standard, and thus is not an ANSI C header file, but it exists in many C language dialects. It is available with Borland Turbo C and  TIGCC. This header file provides operations regarding Dynamic Memory Allocation. This header file includes "memory management" functions.

Example usage
To use the functions in, we must include   before we use them.

Predefined types

 * Bool

It is an enumeration. It has defined two binary values false and true. Constant  stands for logic 0 while constant   stands for logic 1.


 * HANDLE

A handle represents an allocated, aligned block of memory. Its address can be retrieved by means of  function in. HANDLE is used for managing the memory allocated by the functions of. Some functions from other header files use HANDLE as parameter.

Deviation from standards

 * The alloca function is different from the standard   function, in that malloc allocates memory in memory heap whereas   allocates it in stack memory. Hence, this storage is local. Within a function, if memory is allocated using , it is deallocated automatically at the end of function.   is more preferred in applications which require local Dynamic Memory Allocation.


 * allocates given byte-block in linear order. It requires continuous block of memory.  allocates memory which is stored in linked list structure. It is advantageous.


 * Many a times, memory blocks are reserved. The memory blocks which are locked for a long time should be moved high in the heap. This reduces interference of such blocks with rest of the system. This can be achieved by using  function. This rearranges the heap before requested memory allocation.


 * When we call, memory manager assigns a pointer known as handle to allocated block. For each block Handles are assigned. So, when we want to use a large number of small size memory blocks,   is not quite efficient. Due to large number of Handles, handling becomes difficult. So,   is better option in such cases.


 * function from "alloc.h" does the job similar to realloc. In case of,  if reallocation fails, it deallocates previously allocated memory. Usually, realloc keeps previously allocated memory block intact.