Commit 065c3720 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Add a test in case realloc failed

parent 5b50c865
......@@ -49,10 +49,12 @@ Created on: Apr 28, 2011
/// Clip the value on the number between 0 and 255. Usefull to convert any number to a uchar.
#define CLIP_UCHAR(x) (uchar)((x) < 0 ? 0 : ((x) >= 256 ? 255 : (x)))
///Shorcut to do a loop from 0 to max-1 element. If it is not break, the last iterator after the loop is max.
/**Shorcut to do a loop from 0 to max-1 element. If it is not broken, the last iterator after the loop is max.
You should not modify the iterator yourself, in this case use a standard for(;;) */
#define FOR(iterator, max) for (iterator = 0; iterator != max; ++iterator)
///Shorcut to do a loop from max-1 elements to 0. This is a bit faster. If it is not broken, the last iterator after the loop is -1.
/**Shorcut to do a loop from max-1 elements to 0. This is a bit faster. If it is not broken, the last iterator after the loop is -1.
You should not modify the iterator yourself, in this case use a standard for(;;) */
#define FOR_INV(iterator, max) for (iterator = max; iterator--;)
/// Do a modulo even with negative numbers.
......
......@@ -139,6 +139,7 @@ void *secure_malloc(const char *file, const char *function, int line, size_t siz
void secure_realloc(const char *file, const char *function, int line, void** pointer, size_t size)
{
SYSTEM_ERROR_CHECK(*pointer = realloc(*pointer, size), NULL, "size: '%lu'", size);
if (*pointer == NULL) fatal_error(file, function, line, "realloc of size '%lu' has failed (return NULL)", size);
}
void *append_allocation(const char *file, const char *function, int line, void** pointer, size_t pointer_content_size, int *items_nb, size_t item_size)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment