Continue porting to new format.
This commit is contained in:
1 parent
229d21ef72
commit
f3b6ee0190
1 file changed
+8
-2
+8
-2
@@ -158,7 +158,13 @@ string_clear_get_str(string_t v)
|
|||||||
char *p = v->ptr;
|
char *p = v->ptr;
|
||||||
if (string_int_stack_p(v)) {
|
if (string_int_stack_p(v)) {
|
||||||
// TODO use MEMORY_REALLOC
|
// TODO use MEMORY_REALLOC
|
||||||
p = strdup(p);
|
size_t alloc = string_size(v)+1;
|
||||||
|
char *ptr = M_MEMORY_REALLOC (char, NULL, alloc);
|
||||||
|
if (M_UNLIKELY (ptr == NULL)) {
|
||||||
|
M_MEMORY_FULL(sizeof (char) * alloc);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
memcpy(ptr, p, alloc);
|
||||||
}
|
}
|
||||||
v->ptr = NULL;
|
v->ptr = NULL;
|
||||||
return p;
|
return p;
|
||||||
@@ -1307,7 +1313,7 @@ string_utf8_p(string_t str)
|
|||||||
*/
|
*/
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
# define STRING_CTE(s) \
|
# define STRING_CTE(s) \
|
||||||
((const string_t){{.size = sizeof(s)-1, .alloc = sizeof(s), \
|
((const string_t){{.u.heap = { .size = sizeof(s)-1, .alloc = sizeof(s) } , \
|
||||||
.ptr = ((struct { long long _n; char _d[sizeof (s)]; }){ 0, s })._d }})
|
.ptr = ((struct { long long _n; char _d[sizeof (s)]; }){ 0, s })._d }})
|
||||||
#else
|
#else
|
||||||
namespace m_string {
|
namespace m_string {
|
||||||
|
|||||||
Reference in new issue
Block a user