Skip to content

Commit

Permalink
add sdsfreeVoid prototype
Browse files Browse the repository at this point in the history
Signed-off-by: Uri Yagelnik <[email protected]>
  • Loading branch information
uriyage committed Nov 21, 2024
1 parent 7491657 commit 3bbd52c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/io_threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ int tryOffloadFreeObjToIOThreads(robj *obj) {

/* We offload only the free of the ptr that may be allocated by the I/O thread.
* The object itself was allocated by the main thread and will be freed by the main thread. */
IOJobQueue_push(jq, sdsfree, obj->ptr);
IOJobQueue_push(jq, sdsfreeVoid, obj->ptr);
obj->ptr = NULL;
decrRefCount(obj);

Expand Down
7 changes: 0 additions & 7 deletions src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,6 @@ void dismissObject(robj *o, size_t size_hint) {
#endif
}

/* This variant of decrRefCount() gets its argument as void, and is useful
* as free method in data structures that expect a 'void free_object(void*)'
* prototype for the free method. */
void decrRefCountVoid(void *o) {
decrRefCount(o);
}

int checkType(client *c, robj *o, int type) {
/* A NULL is considered an empty key */
if (o && o->type != type) {
Expand Down
7 changes: 7 additions & 0 deletions src/sds.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ void sdsfree(sds s) {
s_free_with_size(sdsAllocPtr(s), sdsAllocSize(s));
}

/* This variant of sdsfree() gets its argument as void, and is useful
* as free method in data structures that expect a 'void free_object(void*)'
* prototype for the free method. */
void sdsfreeVoid(void *s) {
sdsfree(s);
}

/* Set the sds string length to the length as obtained with strlen(), so
* considering as content only up to the first null term character.
*
Expand Down
1 change: 1 addition & 0 deletions src/sds.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ sds sdsempty(void);
sds sdsdup(const sds s);
size_t sdscopytobuffer(unsigned char *buf, size_t buf_len, sds s, uint8_t *hdr_size);
void sdsfree(sds s);
void sdsfreeVoid(void *s);
sds sdsgrowzero(sds s, size_t len);
sds sdscatlen(sds s, const void *t, size_t len);
sds sdscat(sds s, const char *t);
Expand Down
1 change: 0 additions & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -2982,7 +2982,6 @@ void execCommandAbort(client *c, sds error);

/* Object implementation */
void decrRefCount(robj *o);
void decrRefCountVoid(void *o);
void incrRefCount(robj *o);
robj *makeObjectShared(robj *o);
void freeStringObject(robj *o);
Expand Down

0 comments on commit 3bbd52c

Please sign in to comment.