Definition in file eg_mem.h.
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include "eg_macros.h"
Include dependency graph for eg_mem.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | __EG_MEM_FREE_CHECK__ (1 && DEBUG) |
this is used to enable malloc/free tracking and extra debugging | |
#define | EG_MEM_ALIGN(ptr) ((((size_t)ptr)+EG_MEM_ALIGNMENT-1)&(~(EG_MEM_ALIGNMENT-1))) |
Given a pointer, return it's aligned value. | |
#define | EG_MEM_ALIGNMENT 8U |
memory aligment used by EG alloc functions. | |
#define | EG_MEM_ALIGNMENT_SHIFT 3U |
![]() | |
#define | EG_MEM_WORD_SIZE (sizeof(void*)) |
size of a normal word in this machine (a word is just big enough to store a pointer) | |
#define | EGfree(A) |
This function replace free, the idea of this is to HOPEFULLY later develop a memory leack checker that tell us who and where asked for memory and didn't free it, in hte meantime they do nothing. | |
#define | EGmalloc(A) |
this function replace malloc, check if the memory is not zero, if it is, it exit from the program, and display who called it and how much memory it tryed to alloc. | |
#define | EGrealloc(__ptr, __sz) |
Realloc a given pointer to the new size, and check that we find enough memory to return. If we don't, we exit the execution. | |
#define | EGsMalloc(type, count) (type*)EGmalloc(sizeof(type)*(count)) |
This function allocate 'count' elements of type 'type' and return a pointer of type 'type*'. If the memory is not available the program will exit indicating where it was trying to get memory and how much, it will also check some common errors like allocating zero bytes. | |
#define | nullConstructor ((EGconstructor_f)0) |
Null constructor function (do nothing). | |
#define | nullDestructor ((EGdestructor_f)0) |
Null destructor function (do nothing). | |
#define | nullFree ((EGfree_f)0) |
this is the the data free that does nothing, use it when you don't want/need to free the internal list data becouse you will do it elsewere | |
Typedefs | |
typedef void(* | EGconstructor_f )(void *) |
type for constructor functions. Given a pointer to an element of some type, do the internal initialization necesary so that we can work with the lement, such initialization may include allocating some internal memory needed by the structure (not done by the user). This functions must never fail. if some unexpected error does happen inside, then the function should not return. (a call to exit(1) would do the trick). | |
typedef void(* | EGdestructor_f )(void *) |
type for destructor functions. Given a pointer to an element of some type, free all internal memory related to the element allocated during the construction phase. (but not the pointer itself). This function must always succed, if an error happen, the function should never return. (a call to exit(1) would do the trick). | |
typedef void(* | EGfree_f )(void *) |
type of the free functions that recive only one parameter |