MCPcopy Create free account
hub / github.com/acl-dev/acl / acl_debug_strndup

Function acl_debug_strndup

lib_acl/src/stdlib/debug/acl_debug_malloc.c:133–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133static char *acl_debug_strndup(const char *filename, int line, const char *str, size_t size)
134{
135 char key[256], *value;
136 char *ptr;
137 size_t n = strlen(str);
138
139 ASSERT(__debug_mem);
140
141 size--;
142 ASSERT(n > 0);
143 n = n > size ? size : n;
144 ptr = (char*) malloc(n + 1);
145 ASSERT(ptr);
146 memcpy(ptr, str, n);
147 ptr[n] = 0;
148
149 snprintf(key, sizeof(key), "0x%p", ptr);
150 value = (char*) malloc(DLEN);
151 ASSERT(value);
152 snprintf(value, DLEN, "%s%c%d%c%d", filename, SEP, line, SEP, (int) n);
153 LOCK;
154 ASSERT(debug_htable_enter(__debug_mem->table, key, value));
155 UNLOCK;
156 return (ptr);
157}
158
159static void *acl_debug_memdup(const char *filename, int line, const void *data, size_t size)
160{

Callers

nothing calls this directly

Calls 3

mallocFunction · 0.85
memcpyFunction · 0.85
debug_htable_enterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…