Add sdsfreeusable()

This commit is contained in:
Slavomir Kaslev 2025-07-10 23:33:37 +03:00
parent 2e4a7cc991
commit 937835b4b6
2 changed files with 11 additions and 0 deletions

View File

@ -216,6 +216,16 @@ void sdsfree(sds s) {
s_free((char*)s-sdsHdrSize(s[-1]));
}
/* Free an sds string. No operation is performed if 's' is NULL.
* '*usable' is set to the usable size if non NULL */
void sdsfreeusable(sds s, size_t *usable) {
if (s == NULL) {
if (usable) *usable = 0;
return;
}
s_free_usable((char*)s-sdsHdrSize(s[-1]), usable);
}
/* Generic version of sdsfree. */
void sdsfreegeneric(void *s) {
sdsfree((sds)s);

View File

@ -218,6 +218,7 @@ sds sdsnewplacement(char *buf, size_t bufsize, char type, const char *init, size
sds sdsempty(void);
sds sdsdup(const sds s);
void sdsfree(sds s);
void sdsfreeusable(sds s, size_t *usable);
void sdsfreegeneric(void *s);
sds sdsgrowzero(sds s, size_t len);
sds sdscatlen(sds s, const void *t, size_t len);