Memory



next up previous contents index
Next: Strings Up: Predefined functions Previous: Formatted output conversion

Memory

Three memory allocation and free functions are predefined in Smac (see also strdup() §6.6.3 page gif):

malloc

   void * malloc(int size)

malloc returns a pointer on a block of at least size bytes correctly aligned, or 0 on failure (see §6 page gif).

calloc

   void * calloc(int nelt, int eltsize)

calloc returns a pointer to a zero initialized block able to memorize nelt elements of size eltsize, or 0 on failure.

free

   void free(void * ptr)

free releases a block allocated by malloc or calloc.

For performance reasons, a copy function has also been predefined:

memcpy

   char * memcpy(char * to, char * from, int n)

memcpy copies n bytes from from to to.



Lionel Fournigault
Mon Mar 6 13:33:34 MET 1995