MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / zfree_usable

Function zfree_usable

src/zmalloc.cpp:314–330  ·  view source on GitHub ↗

Similar to zfree, '*usable' is set to the usable size being freed. */

Source from the content-addressed store, hash-verified

312
313/* Similar to zfree, '*usable' is set to the usable size being freed. */
314void zfree_usable(void *ptr, size_t *usable) {
315#ifndef HAVE_MALLOC_SIZE
316 void *realptr;
317 size_t oldsize;
318#endif
319
320 if (ptr == NULL) return;
321#ifdef HAVE_MALLOC_SIZE
322 update_zmalloc_stat_free(*usable = zmalloc_size(ptr));
323 free(ptr);
324#else
325 realptr = (char*)ptr-PREFIX_SIZE;
326 *usable = oldsize = *((size_t*)realptr);
327 update_zmalloc_stat_free(oldsize+PREFIX_SIZE);
328 free(realptr);
329#endif
330}
331
332char *zstrdup(const char *s) {
333 size_t l = strlen(s)+1;

Callers

nothing calls this directly

Calls 2

zmalloc_sizeFunction · 0.85
freeFunction · 0.85

Tested by

no test coverage detected