Mercurial > libjeffpc
changeset 481:a99742fc9157
Merge nvval rework
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Thu, 12 Apr 2018 09:46:30 -0400 |
parents | 967763846b84 (current diff) 4241b66d5823 (diff) |
children | a7482bfa78a1 |
files | include/jeffpc/val.h |
diffstat | 3 files changed, 10 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/include/jeffpc/mem.h Thu Apr 12 09:45:07 2018 -0400 +++ b/include/jeffpc/mem.h Thu Apr 12 09:46:30 2018 -0400 @@ -29,13 +29,6 @@ #include <string.h> /* - * malloc/free wrappers for consistency - */ - -#define mem_alloc(len) malloc(len) -#define mem_free(buf) free(buf) - -/* * zeroed allocation */
--- a/include/jeffpc/val.h Thu Apr 12 09:45:07 2018 -0400 +++ b/include/jeffpc/val.h Thu Apr 12 09:46:30 2018 -0400 @@ -76,8 +76,12 @@ union { const uint64_t i; const bool b; - const char *str_ptr; - const char str_inline[STR_INLINE_LEN + 1]; + struct { + union { + const char *ptr; + const char inline_str[STR_INLINE_LEN + 1]; + }; + } str; const struct { struct val *head; struct val *tail; @@ -330,7 +334,7 @@ VERIFY((val->type == VT_STR) || (val->type == VT_SYM)); - return val->inline_alloc ? val->str_inline : val->str_ptr; + return val->inline_alloc ? val->str.inline_str : val->str.ptr; } static inline const char *str_cstr(const struct str *str) @@ -351,7 +355,7 @@ { \ .val = { \ .type = (t), \ - .str_inline = { (v), '\0' }, \ + .str.inline_str = { (v), '\0' },\ .static_struct = true, \ .static_alloc = true, \ .inline_alloc = true, \ @@ -366,7 +370,7 @@ { \ .val = { \ .type = (t), \ - .str_ptr = (v), \ + .str.ptr = (v), \ .static_struct = true, \ .static_alloc = true, \ } \
--- a/str.c Thu Apr 12 09:45:07 2018 -0400 +++ b/str.c Thu Apr 12 09:46:30 2018 -0400 @@ -30,7 +30,7 @@ #include "val_impl.h" /* check that STR_INLINE_LEN is used properly in the struct definition */ -STATIC_ASSERT(STR_INLINE_LEN + 1 == sizeof(((struct str *) NULL)->val.str_inline)); +STATIC_ASSERT(STR_INLINE_LEN + 1 == sizeof(((struct str *) NULL)->val.str.inline_str)); /* check that STR_INLINE_LEN is not undersized */ STATIC_ASSERT(STR_INLINE_LEN + 1 >= sizeof(char *));