implemented node-type in why2_free
This commit is contained in:
parent
2422079bba
commit
86d206ba7b
@ -6,13 +6,15 @@
|
|||||||
|
|
||||||
#include <why2/memory.h>
|
#include <why2/memory.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <why2/flags.h>
|
#include <why2/flags.h>
|
||||||
|
|
||||||
//LOCAL
|
//LOCAL
|
||||||
const enum POINTER_TYPES
|
enum POINTER_TYPES
|
||||||
{
|
{
|
||||||
ALLOCATION,
|
ALLOCATION,
|
||||||
FOPEN,
|
FOPEN,
|
||||||
@ -145,7 +147,20 @@ void why2_free(void *pointer)
|
|||||||
|
|
||||||
if (node != NULL) remove_node(node); //REMOVE FROM LIST IF FOUND
|
if (node != NULL) remove_node(node); //REMOVE FROM LIST IF FOUND
|
||||||
|
|
||||||
free(pointer);
|
switch (node -> type) //DEALLOCATE BY THE CORRECT WAY
|
||||||
|
{
|
||||||
|
case ALLOCATION: //STANDARD MALLOC, CALLOC OR REALLOC
|
||||||
|
free(pointer);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FOPEN: //FOPEN OR FDOPEN
|
||||||
|
fclose(pointer);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPEN: //OPEN SYSTEM CALL
|
||||||
|
close(*((int*) pointer));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void why2_clean_memory(char *identifier)
|
void why2_clean_memory(char *identifier)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user