Skip to content

Commit

Permalink
Adjust adjustTypeIfNeeded if needed
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Söderqvist <[email protected]>
  • Loading branch information
zuiderkwast committed Jan 24, 2025
1 parent 3d1a674 commit 6ba6ea5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sds.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ sds _sdsnewlen(const void *init, size_t initlen, int trymalloc) {
: s_malloc_usable(hdrlen + initlen + 1, &bufsize);
if (sh == NULL) return NULL;

adjustTypeIfNeeded(&type, &hdrlen, bufsize);
return sdswrite(sh, bufsize, type, init, initlen);
}

Expand All @@ -123,8 +122,9 @@ sds _sdsnewlen(const void *init, size_t initlen, int trymalloc) {
* buffer size. You can use a larger `bufsize` than required, but usable size
* can't be greater than `sdsTypeMaxSize(type)`. */
sds sdswrite(char *buf, size_t bufsize, char type, const char *init, size_t initlen) {
assert(bufsize >= sdsReqSize(initlen, type));
int hdrlen = sdsHdrSize(type);
adjustTypeIfNeeded(&type, &hdrlen, bufsize);
assert(bufsize >= sdsReqSize(initlen, type));
size_t usable = bufsize - hdrlen - 1;
sds s = buf + hdrlen;
unsigned char *fp = ((unsigned char *)s) - 1; /* flags pointer. */
Expand Down

0 comments on commit 6ba6ea5

Please sign in to comment.