GenSVM
|
Utility functions for memory allocation. More...
#include "gensvm_globals.h"
Go to the source code of this file.
Functions | |
void * | mycalloc (const char *file, int line, unsigned long size, size_t typesize) |
Wrapper for calloc() which warns when allocation fails. More... | |
void * | mymalloc (const char *file, int line, unsigned long size) |
Wrapper for malloc() which warns when allocation fails. More... | |
void * | myrealloc (const char *file, int line, unsigned long size, void *var) |
Wrapper for realloc() which warns when allocation fails. More... | |
Utility functions for memory allocation.
This file is part of GenSVM.
GenSVM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GenSVM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GenSVM. If not, see http://www.gnu.org/licenses/.
Definition in file gensvm_memory.c.
void* mycalloc | ( | const char * | file, |
int | line, | ||
unsigned long | size, | ||
size_t | typesize | ||
) |
Wrapper for calloc() which warns when allocation fails.
This is a wrapper function around calloc from <stdlib.h>. It tries to allocate the requested memory and checks if the memory was correctly allocated. If not, an error is printed using err(), which describes the file and linenumber and size failed to allocate. After this, the program exits. See also the defines in gensvm_memory.h.
[in] | file | filename used for error printing |
[in] | line | line number used for error printing |
[in] | size | the size to allocate |
[in] | typesize | the size of the type to allocate |
Definition at line 48 of file gensvm_memory.c.
void* mymalloc | ( | const char * | file, |
int | line, | ||
unsigned long | size | ||
) |
Wrapper for malloc() which warns when allocation fails.
This is a wrapper function around malloc from <stdlib.h>. It tries to allocate the requested memory and checks if the memory was correctly allocated. If not, an error is printed using err(), which describes the file and linenumber and size failed to allocate. After this, the program exits. See also the defines in gensvm_memory.h.
[in] | file | filename used for error printing |
[in] | line | line number used for error printing |
[in] | size | the size to allocate |
Definition at line 81 of file gensvm_memory.c.
void* myrealloc | ( | const char * | file, |
int | line, | ||
unsigned long | size, | ||
void * | var | ||
) |
Wrapper for realloc() which warns when allocation fails.
This is a wrapper function around realloc from <stdlib.h>. It tries to reallocate the requested memory and checks if the memory was correctly reallocated. If not, an error is printed using err(), which describes the file and linenumber and size failed to reallocate. After this, the program exits. See also the defines in gensvm_memory.h.
[in] | file | filename used for error printing |
[in] | line | line number used for error printing |
[in] | size | the size to allocate |
[in] | var | the pointer to the memory to reallocate |
Definition at line 113 of file gensvm_memory.c.