cynapses libc alloc functions
[cynapses libc API (internal)]

Collaboration diagram for cynapses libc alloc functions:


Functions

void * c_calloc (size_t count, size_t size)
void * c_malloc (size_t size)
void * c_realloc (void *ptr, size_t size)
char * c_strdup (const char *str)
char * c_strndup (const char *str, size_t size)


Function Documentation

void* c_calloc ( size_t  count,
size_t  size 
)

Allocates memory for an array.

Allocates memory for an array of <count> elements of <size> bytes each and returns a pointer to the allocated memory. The memory is set to zero.

Parameters:
count Amount of elements to allocate
size Size in bytes of each element to allocate.
Returns:
A unique pointer value that can later be successfully passed to free(). If size or count is 0, NULL will be returned.

void* c_malloc ( size_t  size  ) 

Allocates memory for an array.

Allocates <size> bytes of memory. The memory is set to zero.

Parameters:
size Size in bytes to allocate.
Returns:
A unique pointer value that can later be successfully passed to free(). If size or count is 0, NULL will be returned.

void* c_realloc ( void *  ptr,
size_t  size 
)

Changes the size of the memory block pointed to.

Newly allocated memory will be uninitialized.

Parameters:
ptr Pointer to the memory which should be resized.
size Value to resize.
Returns:
If ptr is NULL, the call is equivalent to c_malloc(size); if size is equal to zero, the call is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an earlier call to c_malloc(), c_calloc() or c_realloc(). If the area pointed to was moved, a free(ptr) is done.

char* c_strdup ( const char *  str  ) 

Duplicate a string.

The function returns a pointer to a newly allocated string which is a duplicate of the string str.

Parameters:
str String to duplicate.
Returns:
Returns a pointer to the duplicated string, or NULL if insufficient memory was available.

char* c_strndup ( const char *  str,
size_t  size 
)

Duplicate a string.

The function returns a pointer to a newly allocated string which is a duplicate of the string str of size bytes.

Parameters:
str String to duplicate.
size Size of the string to duplicate.
Returns:
Returns a pointer to the duplicated string, or NULL if insufficient memory was available. A terminating null byte '' is added.


Generated on Mon May 4 17:43:41 2009 for doc by  doxygen 1.5.6