Skip to content

Commit

Permalink
Delete dead code "zfree_usable" (valkey-io#518)
Browse files Browse the repository at this point in the history
Implemented in
valkey-io@3945a32#diff-a154d1fa454a9868e2c455acdae971e3605151516f9a8efac7f2c9b2845d914d,
this function is never called and never used. I was trying to understand
whether we could use this for another PR, but couldn't really find a
point for it because it didn't do exactly what I expected.

Signed-off-by: Madelyn Olson <[email protected]>
  • Loading branch information
madolson authored May 20, 2024
1 parent 122cba5 commit acb74f8
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/sdsalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,5 @@
#define s_realloc_usable zrealloc_usable
#define s_trymalloc_usable ztrymalloc_usable
#define s_tryrealloc_usable ztryrealloc_usable
#define s_free_usable zfree_usable

#endif
19 changes: 0 additions & 19 deletions src/zmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,25 +381,6 @@ void zfree(void *ptr) {
#endif
}

/* Similar to zfree, '*usable' is set to the usable size being freed. */
void zfree_usable(void *ptr, size_t *usable) {
#ifndef HAVE_MALLOC_SIZE
void *realptr;
size_t oldsize;
#endif

if (ptr == NULL) return;
#ifdef HAVE_MALLOC_SIZE
update_zmalloc_stat_free(*usable = zmalloc_size(ptr));
free(ptr);
#else
realptr = (char*)ptr-PREFIX_SIZE;
*usable = oldsize = *((size_t*)realptr);
update_zmalloc_stat_free(oldsize+PREFIX_SIZE);
free(realptr);
#endif
}

char *zstrdup(const char *s) {
size_t l = strlen(s)+1;
char *p = zmalloc(l);
Expand Down
1 change: 0 additions & 1 deletion src/zmalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ void *zrealloc_usable(void *ptr, size_t size, size_t *usable);
void *ztrymalloc_usable(size_t size, size_t *usable);
void *ztrycalloc_usable(size_t size, size_t *usable);
void *ztryrealloc_usable(void *ptr, size_t size, size_t *usable);
void zfree_usable(void *ptr, size_t *usable);
__attribute__((malloc)) char *zstrdup(const char *s);
size_t zmalloc_used_memory(void);
void zmalloc_set_oom_handler(void (*oom_handler)(size_t));
Expand Down

0 comments on commit acb74f8

Please sign in to comment.