Function: | memset |
---|---|
Prototype: | void memset( void* destination, int value, int size ) |
Description: | Sets all words in the target memory region to the same given value |
Arguments: | |
void* destination | Pointer to the beginning of destination region |
int value | Value to which words will be set |
int size | Number of words to set |
Function: | memcpy |
---|---|
Prototype: | void memcpy( void* destination, void* source, int size ) |
Description: | Copies the contents of the given source memory region into the destination region |
Arguments: | |
void* destination | Pointer to the beginning of destination region |
void* source | Pointer to the beginning of source region |
int size | Number of words to copy |
Function: | memcmp |
---|---|
Prototype: | int memcmp( void* region1, void* region2, int size ) |
Description: | Compares the contents of the 2 given memory regions |
Returns: | |
int | A positive result if values from region1 are greater than those of region2. Negative if values from region1 are less than those of region2. Zero when equal |
Arguments: | |
void* region1 | Pointer to the beginning of memory region 1 |
void* region2 | Pointer to the beginning of memory region 2 |
int size | Number of words to compare |
Function: | malloc |
---|---|
Prototype: | void* malloc( int size ) |
Description: | Allocates the requested amount of memory and returns a pointer to its start address |
Returns: | |
void* | Pointer to the beginning of the allocated memory region, or NULL on failure |
Arguments: | |
int size | Number of words to allocate |
Function: | free |
---|---|
Prototype: | void free( void* ptr ) |
Description: | Releases memory allocation of a pointer previously returned by malloc, calloc or realloc. Note it does not set ptr to NULL. Calling free with an invalid ptr will cause memory corrpution! |
Arguments: | |
void* ptr | Pointer to the beginning of a previously allocated memory region |
Function: | calloc |
---|---|
Prototype: | void* calloc( int number, int size ) |
Description: | Allocates memory for the requested number of elements, of the same size each. It also initializes memory to zeroes |
Returns: | |
void* | Pointer to the beginning of the allocated memory region, or NULL on failure |
Arguments: | |
int number | Number of elements to allocate |
int size | Size in words of each element |
Function: | realloc |
---|---|
Prototype: | void* realloc( void* ptr, int size ) |
Description: | Reallocates a previously allocated region with a new size. When possible it will keep the same location, otherwise it will copy all data in the previous region to the new location. If new size is smaller, previous data will get truncated in place. Calling realloc with an invalid ptr will cause memory corrpution! |
Returns: | |
void* | Pointer to beginning of the reallocated memory region, or NULL on failure |
Arguments: | |
void* ptr | Pointer to the beginning of a previously allocated memory region |
int size | New size in words for the reallocated memory region |
Function: | rand |
---|---|
Prototype: | int rand() |
Description: | Generates and returns the next pseudo-random number |
Returns: | |
int | The created value |
Function: | srand |
---|---|
Prototype: | void srand( int seed ) |
Description: | Sets the seed for the pseudo-random number generator. This value will be the first one obtained on next calls to rand(). For a same seed the sequence of values obtained will be the same |
Arguments: | |
int seed | The new seed to use. Cannot be zero (int that case it is ignored) |