summaryrefslogtreecommitdiff
path: root/mem/mem.cpp
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrikboy@gmail.com>2024-03-15 19:21:35 +0100
committerAldrik Ramaekers <aldrikboy@gmail.com>2024-03-15 19:21:35 +0100
commit9dae91f1993c563cf97a87b84836dc3b6306714a (patch)
treeb0b8ec366fc4d3c64615a1a47222d9f278870d57 /mem/mem.cpp
parenteeed387a65d9dbdafddffab8e6f8b507262ffaf5 (diff)
remove mem
Diffstat (limited to 'mem/mem.cpp')
-rw-r--r--mem/mem.cpp85
1 files changed, 0 insertions, 85 deletions
diff --git a/mem/mem.cpp b/mem/mem.cpp
deleted file mode 100644
index 43f5a89..0000000
--- a/mem/mem.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-#define _CRT_SECURE_NO_WARNINGS
-
-#include <stdlib.h>
-#include <stdio.h>
-#ifndef _WIN32
-#include <unistd.h>
-#endif
-#pragma warning(disable : 4996)
-void *debug_malloc(size_t size, const char* file, int line) {
- void *p = malloc(size);
-
- if (p == NULL) {
- return NULL;
- }
-
- char buff[256];
-
- sprintf(buff, "bin/debug/mem/%p.mem", p);
-
- FILE *f = fopen(buff, "w");
- if (!f) return p;
- fprintf(f, "File: %s\nLine: %d\nSize: %zu bytes\n", file, line, size);
- fclose(f);
-
- return p;
-}
-
-void *debug_calloc(size_t count, size_t size, const char* file, int line) {
- void *p = calloc(count, size);
-
- if (p == NULL) {
- return NULL;
- }
-
- char buff[256];
-
- sprintf(buff, "bin/debug/mem/%p.mem", p);
-
- FILE *f = fopen(buff, "w");
- if (!f) return p;
-
- fprintf(f, "File: %s\nLine: %d\nSize: %zu bytes\n", file, line,
- count * size);
- fclose(f);
-
- return p;
-}
-
-void *debug_realloc(void *ptr, size_t size, const char* file, int line) {
- void *p = realloc(ptr, size);
-
- if (p == NULL) {
- return NULL;
- }
-
- char buff[256];
- //Delete the old pointer record
- sprintf(buff, "bin/debug/mem/%p.mem", ptr);
- if (ptr != NULL && unlink(buff) < 0) {
- printf("Double free: %p File: %s Line: %d\n", ptr, file, line);
- }
-
- //Create the new pointer record
- sprintf(buff, "bin/debug/mem/%p.mem", p);
-
- FILE *f = fopen(buff, "w");
- if (!f) return p;
-
- fprintf(f, "File: %s\nLine: %d\nSize: %zu bytes\n", file, line, size);
- fclose(f);
-
- return p;
-}
-
-void debug_free(void *p, const char* file, int line) {
- char buff[256];
-
- sprintf(buff, "bin/debug/mem/%p.mem", p);
- if (p != NULL && unlink(buff) < 0) {
- printf("Double free: %p File: %s Line: %d\n", p, file, line);
- }
-
- free(p);
-}
-