Freeciv-3.3
|
#include <stdlib.h>
#include <string.h>
#include "fcintl.h"
#include "log.h"
#include "shared.h"
#include "mem.h"
Go to the source code of this file.
Functions | |
static void | handle_alloc_failure (size_t size, const char *called_as, int line, const char *file) |
void * | fc_real_malloc (size_t size, const char *called_as, int line, const char *file) |
void * | fc_real_realloc (void *ptr, size_t size, const char *called_as, int line, const char *file) |
void * | fc_real_calloc (size_t nelem, size_t elsize, const char *called_as, int line, const char *file) |
char * | real_fc_strdup (const char *str, const char *called_as, int line, const char *file) |
void * fc_real_calloc | ( | size_t | nelem, |
size_t | elsize, | ||
const char * | called_as, | ||
int | line, | ||
const char * | file | ||
) |
Function used by fc_calloc() macro, calloc() replacement No need to check return value.
I'm pretty sure only the product of nelem and elsize can ever matter here, and not their individual values. (As a matter of C.) Except this function doesn't support calloc-ing more memory than can be expressing using a single size_t, but that's not likely to be a problem.
Function used by fc_malloc() macro, malloc() replacement
There's no need for the caller to check return value; this function will always return a valid pointer (even for a 0-byte malloc).
Definition at line 73 of file mem.c.
Referenced by fc_real_calloc(), fc_real_realloc(), and real_fc_strdup().
void * fc_real_realloc | ( | void * | ptr, |
size_t | size, | ||
const char * | called_as, | ||
int | line, | ||
const char * | file | ||
) |
Function used by fc_realloc() macro, realloc() replacement No need to check return value.
|
static |
Do whatever we should do when fc_malloc() fails. At the moment this just prints a log message and calls exit(EXIT_FAILURE)
Definition at line 38 of file mem.c.
Referenced by fc_real_malloc(), and fc_real_realloc().