defined POINTER_TYPES in memory and implemented it
This commit is contained in:
parent
9d0081ac8f
commit
2422079bba
@ -12,16 +12,24 @@
|
|||||||
#include <why2/flags.h>
|
#include <why2/flags.h>
|
||||||
|
|
||||||
//LOCAL
|
//LOCAL
|
||||||
|
const enum POINTER_TYPES
|
||||||
|
{
|
||||||
|
ALLOCATION,
|
||||||
|
FOPEN,
|
||||||
|
OPEN
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct node
|
typedef struct node
|
||||||
{
|
{
|
||||||
void *pointer;
|
void *pointer;
|
||||||
char *identifier;
|
char *identifier;
|
||||||
|
enum POINTER_TYPES type;
|
||||||
struct node *next;
|
struct node *next;
|
||||||
} node_t; //SINGLE LINKED LIST
|
} node_t; //SINGLE LINKED LIST
|
||||||
|
|
||||||
node_t *head = NULL;
|
node_t *head = NULL;
|
||||||
|
|
||||||
void push_to_list(void *pointer)
|
void push_to_list(void *pointer, enum POINTER_TYPES type)
|
||||||
{
|
{
|
||||||
//CREATE NODE
|
//CREATE NODE
|
||||||
node_t *new_node = malloc(sizeof(node_t));
|
node_t *new_node = malloc(sizeof(node_t));
|
||||||
@ -29,6 +37,7 @@ void push_to_list(void *pointer)
|
|||||||
|
|
||||||
new_node -> pointer = pointer;
|
new_node -> pointer = pointer;
|
||||||
new_node -> identifier = why2_get_memory_identifier();
|
new_node -> identifier = why2_get_memory_identifier();
|
||||||
|
new_node -> type = type;
|
||||||
new_node -> next = NULL;
|
new_node -> next = NULL;
|
||||||
|
|
||||||
if (head == NULL) //INIT LIST
|
if (head == NULL) //INIT LIST
|
||||||
@ -95,7 +104,7 @@ void *why2_malloc(unsigned long size)
|
|||||||
{
|
{
|
||||||
void *allocated = malloc(size);
|
void *allocated = malloc(size);
|
||||||
|
|
||||||
push_to_list(allocated);
|
push_to_list(allocated, ALLOCATION);
|
||||||
|
|
||||||
return allocated;
|
return allocated;
|
||||||
}
|
}
|
||||||
@ -104,7 +113,7 @@ void *why2_calloc(unsigned long element, unsigned long size)
|
|||||||
{
|
{
|
||||||
void *allocated = calloc(element, size);
|
void *allocated = calloc(element, size);
|
||||||
|
|
||||||
push_to_list(allocated);
|
push_to_list(allocated, ALLOCATION);
|
||||||
|
|
||||||
return allocated;
|
return allocated;
|
||||||
}
|
}
|
||||||
@ -115,7 +124,7 @@ void *why2_realloc(void *pointer, unsigned long size)
|
|||||||
|
|
||||||
void *allocated = malloc(size);
|
void *allocated = malloc(size);
|
||||||
|
|
||||||
push_to_list(allocated);
|
push_to_list(allocated, ALLOCATION);
|
||||||
|
|
||||||
return allocated;
|
return allocated;
|
||||||
}
|
}
|
||||||
@ -124,7 +133,7 @@ char *why2_strdup(char *string)
|
|||||||
{
|
{
|
||||||
char *allocated = strdup(string);
|
char *allocated = strdup(string);
|
||||||
|
|
||||||
push_to_list(allocated);
|
push_to_list(allocated, ALLOCATION);
|
||||||
|
|
||||||
return allocated;
|
return allocated;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user