|
MentOS
0.8.0
The Mentoring Operating System
|
Classes | |
| struct | malloc_header_t |
| A structure that holds the information about an allocated chunk of memory through malloc. More... | |
Macros | |
| #define | MALLOC_MAGIC_NUMBER 0x600DC0DE |
| Number which identifies a memory area allocated through a call to malloc(), calloc() or realloc(). | |
Functions | |
| static void * | malloc_header_to_ptr (malloc_header_t *header) |
| Extract the actual pointer to the allocated memory from the malloc header. More... | |
| static malloc_header_t * | ptr_to_malloc_header (void *ptr) |
| Extract the malloc header, from the actual pointer to the allocated memory. More... | |
| void * | malloc (unsigned int size) |
| Provides dynamically allocated memory. More... | |
| void * | calloc (size_t num, size_t size) |
| Allocates a block of memory for an array of num elements. More... | |
| void * | realloc (void *ptr, size_t size) |
| Reallocates the given area of memory. More... | |
| void | free (void *ptr) |
| Frees dynamically allocated memory. More... | |
| void | srand (unsigned x) |
| Allows to set the seed of the random value generator. More... | |
| unsigned | rand (void) |
| Generates a random unsigned integer between 0 and RAND_MAX. More... | |
| float | randf (void) |
| Generates a random floating point number between 0 and 1. More... | |
| int | randint (int lb, int ub) |
| Generates a random integer between lb and ub. More... | |
| unsigned | randuint (unsigned lb, unsigned ub) |
| Generates a random unsigned between lb and ub. More... | |
| float | randfloat (float lb, float ub) |
| Generates a random float between lb and ub. More... | |
Variables | |
| static unsigned | rseed = 0 |
| Seed used to generate random numbers. | |
Allocates a block of memory for an array of num elements.
| num | The number of elements. |
| size | The size of an element. |
| void free | ( | void * | ptr | ) |
Frees dynamically allocated memory.
| ptr | The pointer to the allocated memory. |
| void* malloc | ( | unsigned int | size | ) |
Provides dynamically allocated memory.
| size | The amount of memory to allocate. |
|
inlinestatic |
Extract the actual pointer to the allocated memory from the malloc header.
| header | the header we are using. |
|
inlinestatic |
Extract the malloc header, from the actual pointer to the allocated memory.
| ptr | the pointer we use. |
| unsigned rand | ( | void | ) |
Generates a random unsigned integer between 0 and RAND_MAX.
| float randf | ( | void | ) |
Generates a random floating point number between 0 and 1.
| float randfloat | ( | float | lb, |
| float | ub | ||
| ) |
Generates a random float between lb and ub.
| lb | the lower-bound value. |
| ub | the upper-bound value. |
| int randint | ( | int | lb, |
| int | ub | ||
| ) |
Generates a random integer between lb and ub.
| lb | the lower-bound value. |
| ub | the upper-bound value. |
| unsigned randuint | ( | unsigned | lb, |
| unsigned | ub | ||
| ) |
Generates a random unsigned between lb and ub.
| lb | the lower-bound value. |
| ub | the upper-bound value. |
| void* realloc | ( | void * | ptr, |
| size_t | size | ||
| ) |
Reallocates the given area of memory.
| ptr | The pointer to the memory to reallocate. |
| size | The new size for the memory. |
It must be previously allocated by malloc(), calloc() or realloc() and not yet freed with a call to free or realloc. Otherwise, the results are undefined.
| void srand | ( | unsigned | x | ) |
Allows to set the seed of the random value generator.
| x | The new seed. |