C Everything
This is a C repository containing a curated set of generic data structures and algorithm.
memory_manager.h File Reference

Contains decalration of structures for maintaing all mem alloc and frees. More...

Go to the source code of this file.

Data Structures

struct  memory_record
 
struct  mem_mamnager
 

Macros

#define get_mem(nmemb, size)   tag_alloc(nmemb, size, __FILE__, __LINE__)
 
#define free_mem(mem_addr)   untag_alloc(mem_addr, __FILE__, __LINE__)
 
#define FREE_MEM   untag_alloc
 

Typedefs

typedef struct memory_record t_mem_record
 
typedef struct mem_mamnager t_mem_manager
 

Functions

void mem_init (void)
 
Initailize memory module More...
 
void mem_finit (void)
 
Close memory module by checking and destroying if any tagged memory More...
 
void * tag_alloc (size_t nmemb, size_t size, char *file, int line)
 
allocate memory and store in mem list (tagging) More...
 
void untag_alloc (void *mem_addr, char *file, int line)
 
deallocate memory and remove from mem list (untagging) More...
 
void mem_alloc_report (void)
 
print report of all the assigned memory More...
 

Detailed Description

Contains decalration of structures for maintaing all mem alloc and frees.

Definition in file memory_manager.h.

Macro Definition Documentation

◆ free_mem

#define free_mem (   mem_addr)    untag_alloc(mem_addr, __FILE__, __LINE__)

Definition at line 9 of file memory_manager.h.

◆ FREE_MEM

#define FREE_MEM   untag_alloc

Definition at line 10 of file memory_manager.h.

◆ get_mem

#define get_mem (   nmemb,
  size 
)    tag_alloc(nmemb, size, __FILE__, __LINE__)

Definition at line 8 of file memory_manager.h.

Typedef Documentation

◆ t_mem_manager

typedef struct mem_mamnager t_mem_manager

◆ t_mem_record

typedef struct memory_record t_mem_record

Function Documentation

◆ mem_alloc_report()

void mem_alloc_report ( void  )


print report of all the assigned memory

Returns
- NA

Definition at line 110 of file memory_manager.c.

◆ mem_finit()

void mem_finit ( void  )


Close memory module by checking and destroying if any tagged memory

Returns
- NA

Definition at line 24 of file memory_manager.c.

◆ mem_init()

void mem_init ( void  )


Initailize memory module

Returns
- NA

Definition at line 13 of file memory_manager.c.

◆ tag_alloc()

void* tag_alloc ( size_t  nmemb,
size_t  size,
char *  file,
int  line 
)


allocate memory and store in mem list (tagging)

Returns
- memory address

Definition at line 44 of file memory_manager.c.

◆ untag_alloc()

void untag_alloc ( void *  mem_addr,
char *  file,
int  line 
)


deallocate memory and remove from mem list (untagging)

Returns
- memory address

Definition at line 78 of file memory_manager.c.