created why2_allocated fn

checks for why2-mem allocation
This commit is contained in:
Václav Šmejkal 2024-04-20 11:22:09 +02:00
parent 19ccc45e0a
commit 65135ac961
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
2 changed files with 9 additions and 0 deletions

View File

@ -23,6 +23,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
extern "C" {
#endif
#include <why2/flags.h>
void *why2_malloc(unsigned long size);
void *why2_calloc(unsigned long element, unsigned long size);
void *why2_realloc(void *pointer, unsigned long size);
@ -37,6 +39,8 @@ void why2_deallocate(void *pointer);
void why2_clean_memory(char *identifier); //identifier SPECIFIES WHICH NODES TO DEALLOCATE | THIS IS BASICALLY GARBAGE COLLECTOR | PASS why2_get_default_memory_identifier() FOR DEALLOCATING EVERYTHING
why2_bool why2_allocated(void *pointer); //CHECKS IF pointer WAS ALLOCATED USING WHY2-MEM
#ifdef __cplusplus
}
#endif

View File

@ -240,4 +240,9 @@ void why2_clean_memory(char *identifier)
if (buffer -> identifier == identifier || force_deallocating) why2_deallocate(buffer -> pointer); //LAST NODE
why2_reset_memory_identifier(); //THIS WILL CAUSE SEGFAULT IF YOU DIDN'T USE why2_set_memory_identifier
}
why2_bool why2_allocated(void *pointer)
{
return get_node(pointer) != NULL;
}