object: string: fix b_string_steal resetting capacity to wrong value

This commit is contained in:
2024-11-17 09:22:39 +00:00
parent e37d6bb3b3
commit 2531f00b81
2 changed files with 7 additions and 7 deletions

View File

@@ -48,7 +48,7 @@ static char *string_ptr(struct b_string *str)
return str->s_data.d_inline;
}
return str->s_data.d_BLUE_APIal;
return str->s_data.d_external;
}
static int string_make_inline(struct b_string *str)
@@ -76,7 +76,7 @@ static int string_resize_large(struct b_string *str, size_t capacity)
}
str->s_max = capacity;
str->s_data.d_BLUE_APIal = new_buffer;
str->s_data.d_external = new_buffer;
return 0;
}
@@ -92,7 +92,7 @@ static int string_make_large(struct b_string *str, size_t capacity)
buffer[str->s_len] = '\0';
str->s_max = capacity;
str->s_data.d_BLUE_APIal = buffer;
str->s_data.d_external = buffer;
return 0;
}
@@ -178,8 +178,8 @@ char *b_string_steal(struct b_string *str)
dest = b_strdup(src);
} else {
dest = src;
str->s_data.d_BLUE_APIal = NULL;
str->s_max = 0;
str->s_data.d_external = NULL;
str->s_max = STRING_INLINE_CAPACITY;
}
str->s_len = 0;
@@ -318,7 +318,7 @@ const char *b_string_ptr(const struct b_string *str)
return str->s_data.d_inline;
}
return str->s_data.d_BLUE_APIal;
return str->s_data.d_external;
}
static void string_release(struct b_object *obj)

View File

@@ -14,7 +14,7 @@ struct b_string {
unsigned int s_max;
union {
char d_inline[STRING_INLINE_CAPACITY + 1];
char *d_BLUE_APIal;
char *d_external;
} s_data;
};