GenSVM
|
Header file for gensvm_memory.c. More...
#include <stddef.h>
Go to the source code of this file.
Macros | |
#define | Calloc(type, size) mycalloc(__FILE__, __LINE__, size, sizeof(type)) |
#define | Malloc(type, size) mymalloc(__FILE__, __LINE__, (size)*sizeof(type)) |
#define | Realloc(var, type, size) myrealloc(__FILE__, __LINE__, (size)*sizeof(type), var) |
#define | Memset(var, type, size) memset(var, 0, (size)*sizeof(type)) |
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... | |
Header file for gensvm_memory.c.
Contains macro definitions for easy memory access.
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.h.
#define Calloc | ( | type, | |
size | |||
) | mycalloc(__FILE__, __LINE__, size, sizeof(type)) |
Wrapper macro for mycalloc(). This macro uses the FILE and LINE standard macros to fill in some of the arguments to mycalloc(). This macro should be used when writing code, not mycalloc().
Definition at line 40 of file gensvm_memory.h.
#define Malloc | ( | type, | |
size | |||
) | mymalloc(__FILE__, __LINE__, (size)*sizeof(type)) |
Wrapper macro for mymalloc(). This macro uses the FILE and LINE standard macros to fill in some of the arguments to mymalloc(). This macro should be used when writing code, not mymalloc().
Definition at line 48 of file gensvm_memory.h.
#define Memset | ( | var, | |
type, | |||
size | |||
) | memset(var, 0, (size)*sizeof(type)) |
Wrapper macro for memset(). Since memset is only used to zero a matrix, this macro is defined.
Definition at line 61 of file gensvm_memory.h.
#define Realloc | ( | var, | |
type, | |||
size | |||
) | myrealloc(__FILE__, __LINE__, (size)*sizeof(type), var) |
Wrapper macro for myrealloc(). This macro uses the FILE and LINE standard macros to fill in some of the arguments to myrealloc(). This macro should be used when writing code, not myrealloc().
Definition at line 55 of file gensvm_memory.h.
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.