feat(lsm): add some attr & data support functions; fix str bug
This commit is contained in:
parent
fbf6557c05
commit
8b6d1f6e91
4 changed files with 91 additions and 11 deletions
|
|
@ -77,16 +77,16 @@ lsm_error lsm_str_overwrite_copy(lsm_str *str, char *s) {
|
|||
}
|
||||
|
||||
lsm_error lsm_str_overwrite_copy_n(lsm_str *str, char *s, uint64_t len) {
|
||||
if (str->len <= 8) {
|
||||
memcpy(str->data.val, s, str->len);
|
||||
if (len <= 8) {
|
||||
memcpy(str->data.val, s, len);
|
||||
} else {
|
||||
char *buf = malloc(str->len * sizeof(char));
|
||||
char *buf = malloc(len * sizeof(char));
|
||||
|
||||
if (buf == NULL) {
|
||||
return lsm_error_failed_alloc;
|
||||
}
|
||||
|
||||
memcpy(buf, s, str->len);
|
||||
memcpy(buf, s, len);
|
||||
str->data.ptr = buf;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue