MCPcopy Create free account
hub / github.com/F-Stack/f-stack / activeDefragAlloc

Function activeDefragAlloc

app/redis-6.2.6/src/defrag.c:56–71  ·  view source on GitHub ↗

Defrag helper for generic allocations. * * returns NULL in case the allocation wasn't moved. * when it returns a non-null value, the old pointer was already released * and should NOT be accessed. */

Source from the content-addressed store, hash-verified

54 * when it returns a non-null value, the old pointer was already released
55 * and should NOT be accessed. */
56void* activeDefragAlloc(void *ptr) {
57 size_t size;
58 void *newptr;
59 if(!je_get_defrag_hint(ptr)) {
60 server.stat_active_defrag_misses++;
61 return NULL;
62 }
63 /* move this allocation to a new allocation.
64 * make sure not to use the thread cache. so that we don't get back the same
65 * pointers we try to free */
66 size = zmalloc_size(ptr);
67 newptr = zmalloc_no_tcache(size);
68 memcpy(newptr, ptr, size);
69 zfree_no_tcache(ptr);
70 return newptr;
71}
72
73/*Defrag helper for sds strings
74 *

Callers 15

activeDefragSdsFunction · 0.85
activeDefragStringObFunction · 0.85
dictIterDefragEntryFunction · 0.85
dictDefragTablesFunction · 0.85
zslDefragFunction · 0.85
activeDefragSdsDictFunction · 0.85
activeDefragListFunction · 0.85
defragQuicklistFunction · 0.85
defragZsetSkiplistFunction · 0.85

Calls 4

zmalloc_sizeFunction · 0.85
zmalloc_no_tcacheFunction · 0.85
zfree_no_tcacheFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected