- Fix testbound for alloc stats strdup in util/alloc.c.

This commit is contained in:
W.C.A. Wijngaards 2024-08-02 08:58:22 +02:00
parent befa7d8cd8
commit 6106528a50
2 changed files with 1 additions and 19 deletions

View File

@ -72,23 +72,6 @@ int daemon_main(int argc, char* argv[]);
/** config files (removed at exit) */
static struct config_strlist* cfgfiles = NULL;
#ifdef UNBOUND_ALLOC_STATS
# define strdup(s) unbound_stat_strdup_log(s, __FILE__, __LINE__, __func__)
char* unbound_stat_strdup_log(char* s, const char* file, int line,
const char* func);
char* unbound_stat_strdup_log(char* s, const char* file, int line,
const char* func) {
char* result;
size_t len;
if(!s) return NULL;
len = strlen(s);
log_info("%s:%d %s strdup(%u)", file, line, func, (unsigned)len+1);
result = unbound_stat_malloc(len+1);
memmove(result, s, len+1);
return result;
}
#endif /* UNBOUND_ALLOC_STATS */
/** give commandline usage for testbound. */
static void
testbound_usage(void)

View File

@ -475,8 +475,7 @@ char *unbound_stat_strdup(const char* s)
len = strlen(s);
res = unbound_stat_malloc(len+1);
if(!res) return NULL;
memmove(res, s, len);
res[len]=0;
memmove(res, s, len+1);
return res;
}