diff options
| author | 2022-10-25 13:59:15 +0200 | |
|---|---|---|
| committer | 2022-10-25 13:59:15 +0200 | |
| commit | 78b3a304479ac3063bf75d41ed25539ed474763d (patch) | |
| tree | 5d561ec56847a8c4714b304d43d3ed4999439535 /xs.h | |
| parent | Backport from xs. (diff) | |
| download | snac2-78b3a304479ac3063bf75d41ed25539ed474763d.tar.gz snac2-78b3a304479ac3063bf75d41ed25539ed474763d.tar.xz snac2-78b3a304479ac3063bf75d41ed25539ed474763d.zip | |
Some code moving to avoid false positive leaks.
Diffstat (limited to 'xs.h')
| -rw-r--r-- | xs.h | 21 |
1 files changed, 18 insertions, 3 deletions
| @@ -66,7 +66,7 @@ d_char *xs_list_append_m(d_char *list, const char *mem, int dsz); | |||
| 66 | int xs_list_iter(char **list, char **value); | 66 | int xs_list_iter(char **list, char **value); |
| 67 | int xs_list_len(char *list); | 67 | int xs_list_len(char *list); |
| 68 | char *xs_list_get(char *list, int num); | 68 | char *xs_list_get(char *list, int num); |
| 69 | int xs_list_in(char *list, char *val); | 69 | int xs_list_in(char *list, const char *val); |
| 70 | d_char *xs_join(char *list, const char *sep); | 70 | d_char *xs_join(char *list, const char *sep); |
| 71 | d_char *xs_split_n(const char *str, const char *sep, int times); | 71 | d_char *xs_split_n(const char *str, const char *sep, int times); |
| 72 | #define xs_split(str, sep) xs_split_n(str, sep, 0xfffffff) | 72 | #define xs_split(str, sep) xs_split_n(str, sep, 0xfffffff) |
| @@ -96,12 +96,27 @@ void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char | |||
| 96 | 96 | ||
| 97 | #ifdef XS_DEBUG | 97 | #ifdef XS_DEBUG |
| 98 | if (ndata != ptr) { | 98 | if (ndata != ptr) { |
| 99 | int n; | ||
| 99 | FILE *f = fopen("xs_memory.out", "a"); | 100 | FILE *f = fopen("xs_memory.out", "a"); |
| 100 | 101 | ||
| 101 | if (ptr != NULL) | 102 | if (ptr != NULL) |
| 102 | fprintf(f, "%p r\n", ptr); | 103 | fprintf(f, "%p r\n", ptr); |
| 103 | 104 | ||
| 104 | fprintf(f, "%p a %ld %s %d %s\n", ndata, size, file, line, func); | 105 | fprintf(f, "%p a %ld %s:%d: %s", ndata, size, file, line, func); |
| 106 | |||
| 107 | if (ptr != NULL) { | ||
| 108 | fprintf(f, " ["); | ||
| 109 | for (n = 0; n < 32 && ndata[n]; n++) { | ||
| 110 | if (ndata[n] >= 32 && ndata[n] <= 127) | ||
| 111 | fprintf(f, "%c", ndata[n]); | ||
| 112 | else | ||
| 113 | fprintf(f, "\\%02x", (unsigned char)ndata[n]); | ||
| 114 | } | ||
| 115 | fprintf(f, "]"); | ||
| 116 | } | ||
| 117 | |||
| 118 | fprintf(f, "\n"); | ||
| 119 | |||
| 105 | fclose(f); | 120 | fclose(f); |
| 106 | } | 121 | } |
| 107 | #endif | 122 | #endif |
| @@ -531,7 +546,7 @@ char *xs_list_get(char *list, int num) | |||
| 531 | } | 546 | } |
| 532 | 547 | ||
| 533 | 548 | ||
| 534 | int xs_list_in(char *list, char *val) | 549 | int xs_list_in(char *list, const char *val) |
| 535 | /* returns the position of val in list or -1 */ | 550 | /* returns the position of val in list or -1 */ |
| 536 | { | 551 | { |
| 537 | int n = 0; | 552 | int n = 0; |