diff options
| -rw-r--r-- | xs.h | 16 | ||||
| -rw-r--r-- | xs_version.h | 2 |
2 files changed, 14 insertions, 4 deletions
| @@ -603,6 +603,11 @@ xs_list *_xs_list_write_litem(xs_list *list, int offset, const char *mem, int ds | |||
| 603 | { | 603 | { |
| 604 | XS_ASSERT_TYPE(list, XSTYPE_LIST); | 604 | XS_ASSERT_TYPE(list, XSTYPE_LIST); |
| 605 | 605 | ||
| 606 | if (mem == NULL) { | ||
| 607 | mem = xs_stock_null; | ||
| 608 | dsz = sizeof(xs_stock_null); | ||
| 609 | } | ||
| 610 | |||
| 606 | list = xs_expand(list, offset, dsz + 1); | 611 | list = xs_expand(list, offset, dsz + 1); |
| 607 | 612 | ||
| 608 | list[offset] = XSTYPE_LITEM; | 613 | list[offset] = XSTYPE_LITEM; |
| @@ -899,13 +904,18 @@ xs_dict *xs_dict_new(void) | |||
| 899 | } | 904 | } |
| 900 | 905 | ||
| 901 | 906 | ||
| 902 | xs_dict *xs_dict_insert_m(xs_dict *dict, int offset, const xs_str *key, | 907 | xs_dict *_xs_dict_write_ditem(xs_dict *dict, int offset, const xs_str *key, |
| 903 | const xs_val *data, int dsz) | 908 | const xs_val *data, int dsz) |
| 904 | /* inserts a memory block into the dict */ | 909 | /* inserts a memory block into the dict */ |
| 905 | { | 910 | { |
| 906 | XS_ASSERT_TYPE(dict, XSTYPE_DICT); | 911 | XS_ASSERT_TYPE(dict, XSTYPE_DICT); |
| 907 | XS_ASSERT_TYPE(key, XSTYPE_STRING); | 912 | XS_ASSERT_TYPE(key, XSTYPE_STRING); |
| 908 | 913 | ||
| 914 | if (data == NULL) { | ||
| 915 | data = xs_stock_null; | ||
| 916 | dsz = sizeof(xs_stock_null); | ||
| 917 | } | ||
| 918 | |||
| 909 | int ksz = xs_size(key); | 919 | int ksz = xs_size(key); |
| 910 | 920 | ||
| 911 | dict = xs_expand(dict, offset, 1 + ksz + dsz); | 921 | dict = xs_expand(dict, offset, 1 + ksz + dsz); |
| @@ -921,14 +931,14 @@ xs_dict *xs_dict_insert_m(xs_dict *dict, int offset, const xs_str *key, | |||
| 921 | xs_dict *xs_dict_append_m(xs_dict *dict, const xs_str *key, const xs_val *mem, int dsz) | 931 | xs_dict *xs_dict_append_m(xs_dict *dict, const xs_str *key, const xs_val *mem, int dsz) |
| 922 | /* appends a memory block to the dict */ | 932 | /* appends a memory block to the dict */ |
| 923 | { | 933 | { |
| 924 | return xs_dict_insert_m(dict, xs_size(dict) - 1, key, mem, dsz); | 934 | return _xs_dict_write_ditem(dict, xs_size(dict) - 1, key, mem, dsz); |
| 925 | } | 935 | } |
| 926 | 936 | ||
| 927 | 937 | ||
| 928 | xs_dict *xs_dict_prepend_m(xs_dict *dict, const xs_str *key, const xs_val *mem, int dsz) | 938 | xs_dict *xs_dict_prepend_m(xs_dict *dict, const xs_str *key, const xs_val *mem, int dsz) |
| 929 | /* prepends a memory block to the dict */ | 939 | /* prepends a memory block to the dict */ |
| 930 | { | 940 | { |
| 931 | return xs_dict_insert_m(dict, 4, key, mem, dsz); | 941 | return _xs_dict_write_ditem(dict, 4, key, mem, dsz); |
| 932 | } | 942 | } |
| 933 | 943 | ||
| 934 | 944 | ||
diff --git a/xs_version.h b/xs_version.h index 302245d..9ac34f0 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* f42504297420abef44904644524207f8a1440494 */ | /* ce9e43569a7dd29a85c807e496c335cc4999bafd */ | ||