Skip to content

Commit

Permalink
core: make str_cpy() work with the str_const as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Dec 2, 2023
1 parent bb300ae commit 42d83f4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion str.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ static inline void init_str(str *dest, const char *src)
#define ZSTR(_s) (!(_s).s || (_s).len == 0)
#define ZSTRP(_sp) (!(_sp) || ZSTR(*(_sp)))

static inline str *str_cpy(str *dest, const str *src)
static inline str *_str_cpy(str *dest, const str_const *src)
{
memcpy(dest->s, src->s, src->len);
dest->len = src->len;
return dest;
}

#define str_cpy(dest, src) _str_cpy(dest, str2const(src))

#define STR_L(s) s, strlen(s)

/**
Expand Down

0 comments on commit 42d83f4

Please sign in to comment.