Table 8-1 lists and describes all the memory allocation functions found in the DEC C Run-Time Library (RTL). For a more detailed description of each function, see the Reference Section.
Function | Description |
---|---|
brk, sbrk | Determine the lowest virtual address that is not used with the program. |
calloc, malloc | Allocate an area of memory. |
cfree, free | Make available for reallocation the area allocated by a previous calloc, malloc, or realloc call. |
realloc | Changes the size of the area pointed to by the first argument to the number of bytes given by the second argument. |
strdup | Finds and points to a duplicate string. |
All DEC C RTL functions requiring additional storage from the heap get that storage using the DEC C RTL memory allocation functions malloc, calloc, realloc, free, and cfree. Memory allocated by these functions is quadword-aligned.
The ANSI C standard does not include cfree. For this reason, it is preferable to free memory using the functionally equivalent free function.
The brk and sbrk functions assume that memory can be allocated contiguously from the top of your address space. However, the malloc function and RMS may allocate space from this same address space. You should not use the brk and sbrk functions in conjunction with RMS and DEC C RTL routines that use malloc.
Previous versions of the VAX C RTL documentation indicated that the memory allocation routines used the OpenVMS RTL functions LIB$GET_ VM and LIB$FREE_VM to acquire and return dynamic memory. This is no longer the case; interaction between these routines and the DEC C RTL memory allocation routines is no longer problematic (although LIB$SHOW_VM can no longer be used to track DEC C RTL malloc and free usage).
The routines VAXC$CALLOC_OPT, VAXC$CFREE_OPT, VAXC$FREE_OPT, VAXC$MALLOC_OPT, and VAXC$REALLOC_OPT are now obsolete and should not be used in new development. However, versions of these routines that are equivalent to the standard C memory allocation routines are provided for backward compatibility.