summaryrefslogtreecommitdiff
path: root/xs.h
diff options
context:
space:
mode:
authorGravatar default2022-10-25 10:39:30 +0200
committerGravatar default2022-10-25 10:39:30 +0200
commit641d46cb3dba6fb2671644485189b6efd8082949 (patch)
treea0cbb0558f62b4e49a829622f0e7ab39c0da67a0 /xs.h
parentCall srv_free(). (diff)
downloadsnac2-641d46cb3dba6fb2671644485189b6efd8082949.tar.gz
snac2-641d46cb3dba6fb2671644485189b6efd8082949.tar.xz
snac2-641d46cb3dba6fb2671644485189b6efd8082949.zip
Backport from xs.
Diffstat (limited to 'xs.h')
-rw-r--r--xs.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/xs.h b/xs.h
index 6f3a0ed..7900ea0 100644
--- a/xs.h
+++ b/xs.h
@@ -35,8 +35,8 @@ typedef char d_char;
35#define xs __attribute__ ((__cleanup__ (_xs_destroy))) d_char 35#define xs __attribute__ ((__cleanup__ (_xs_destroy))) d_char
36 36
37void *xs_free(void *ptr); 37void *xs_free(void *ptr);
38void *_xs_realloc(void *ptr, size_t size, const char *file, int line); 38void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func);
39#define xs_realloc(ptr, size) _xs_realloc(ptr, size, __FILE__, __LINE__) 39#define xs_realloc(ptr, size) _xs_realloc(ptr, size, __FILE__, __LINE__, __FUNCTION__)
40int _xs_blk_size(int sz); 40int _xs_blk_size(int sz);
41void _xs_destroy(char **var); 41void _xs_destroy(char **var);
42#define xs_debug() raise(SIGTRAP) 42#define xs_debug() raise(SIGTRAP)
@@ -85,7 +85,7 @@ const char *xs_number_str(const char *v);
85 85
86#ifdef XS_IMPLEMENTATION 86#ifdef XS_IMPLEMENTATION
87 87
88void *_xs_realloc(void *ptr, size_t size, const char *file, int line) 88void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func)
89{ 89{
90 d_char *ndata = realloc(ptr, size); 90 d_char *ndata = realloc(ptr, size);
91 91
@@ -99,9 +99,9 @@ void *_xs_realloc(void *ptr, size_t size, const char *file, int line)
99 FILE *f = fopen("xs_memory.out", "a"); 99 FILE *f = fopen("xs_memory.out", "a");
100 100
101 if (ptr != NULL) 101 if (ptr != NULL)
102 fprintf(f, "%p b\n", ptr); 102 fprintf(f, "%p r\n", ptr);
103 103
104 fprintf(f, "%p a %ld %s %d\n", ndata, size, file, line); 104 fprintf(f, "%p a %ld %s %d %s\n", ndata, size, file, line, func);
105 fclose(f); 105 fclose(f);
106 } 106 }
107#endif 107#endif