|
My library
Library for common tasks
|
Common tasks such as comparing variables, allocate memory. More...
#include "types.h"

Go to the source code of this file.
Functions | |
| int | chooseCmp (const spec_t spec, const void *a, const void *b) |
| Compare two values. More... | |
| int | charCmp (const void *a, const void *b) |
| Compare two chars. More... | |
| int | byteCmp (const void *a, const void *b) |
| Compare two bytes. More... | |
| int | intCmp (const void *a, const void *b) |
| Compare two ints. More... | |
| int | floatCmp (const void *a, const void *b) |
| Compare two floats. More... | |
| int | doubleCmp (const void *a, const void *b) |
| Compare two doubles. More... | |
| int | ptrCmp (const void *a, const void *b) |
| Compare two pointers. More... | |
| void * | saferMalloc (unsigned int bytes) |
| Return a pointer to a space in memory of specified size. More... | |
| void * | saferRealloc (void *pointer, unsigned int bytes) |
| Reallocate a space in memory. More... | |
Common tasks such as comparing variables, allocate memory.
| int byteCmp | ( | const void * | a, |
| const void * | b | ||
| ) |
Compare two bytes.
Equivalent to charCmp(a, b). Refer to charCmp().
| int charCmp | ( | const void * | a, |
| const void * | b | ||
| ) |
Compare two chars.
Equivalent to chooseCmp("%c", a, b). Refer to chooseCmp()
| int chooseCmp | ( | const spec_t | spec, |
| const void * | a, | ||
| const void * | b | ||
| ) |
Compare two values.
| spec | Type specifier of the values to be compared. Refer to spec_t for supported types. |
| a | Pointer to the first element to be compared |
| b | Pointer to the second element to be compared |
| GREATER | First element is grater than the second |
| EQUAL | First element is equal to the second |
| SMALLER | First element is smaller than the second |
| int doubleCmp | ( | const void * | a, |
| const void * | b | ||
| ) |
Compare two doubles.
Equivalent to chooseCmp("%lf", a, b). Refer to chooseCmp()
| int floatCmp | ( | const void * | a, |
| const void * | b | ||
| ) |
Compare two floats.
Equivalent to chooseCmp("%f", a, b). Refer to chooseCmp()
| int intCmp | ( | const void * | a, |
| const void * | b | ||
| ) |
Compare two ints.
Equivalent to chooseCmp("%i", a, b). Refer to chooseCmp()
| int ptrCmp | ( | const void * | a, |
| const void * | b | ||
| ) |
Compare two pointers.
Equivalent to chooseCmp("%p", a, b). Refer to chooseCmp()
| void * saferMalloc | ( | unsigned int | bytes | ) |
Return a pointer to a space in memory of specified size.
Calls malloc(bytes) for a maximum of 10 times until it returns a not null pointer. If in 10 calls does not manage to obtain a not null pointer makes the program terminate
| bytes | Number of bytes to allocate |
| void * saferRealloc | ( | void * | pointer, |
| unsigned int | bytes | ||
| ) |
Reallocate a space in memory.
Calls realloc(pointer, bytes) for a maximum of 10 times until it returns a not null pointer. If in 10 calls does not manage to obtain a not null pointer makes the program terminate
| pointer | Pointer to the memory to be reallocated |
| bytes | Number of bytes to allocate |