summaryrefslogtreecommitdiff
path: root/xs.h
diff options
context:
space:
mode:
authorGravatar default2022-11-24 08:47:02 +0100
committerGravatar default2022-11-24 08:47:02 +0100
commitf2528c6c521cde213e9f7ac3e263b9736d27ef37 (patch)
treef1efdf95b1b933665ed212213abdc0cc9c5f3e56 /xs.h
parentRefuse to store objects that are already here. (diff)
downloadpenes-snac2-f2528c6c521cde213e9f7ac3e263b9736d27ef37.tar.gz
penes-snac2-f2528c6c521cde213e9f7ac3e263b9736d27ef37.tar.xz
penes-snac2-f2528c6c521cde213e9f7ac3e263b9736d27ef37.zip
Backport from xs.
Diffstat (limited to 'xs.h')
-rw-r--r--xs.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/xs.h b/xs.h
index da853f5..9cae3dc 100644
--- a/xs.h
+++ b/xs.h
@@ -34,6 +34,9 @@ typedef char d_char;
34/* auto-destroyable strings */ 34/* auto-destroyable strings */
35#define xs __attribute__ ((__cleanup__ (_xs_destroy))) d_char 35#define xs __attribute__ ((__cleanup__ (_xs_destroy))) d_char
36 36
37/* not really all, just very much */
38#define XS_ALL 0xfffffff
39
37void *xs_free(void *ptr); 40void *xs_free(void *ptr);
38void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func); 41void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func);
39#define xs_realloc(ptr, size) _xs_realloc(ptr, size, __FILE__, __LINE__, __FUNCTION__) 42#define xs_realloc(ptr, size) _xs_realloc(ptr, size, __FILE__, __LINE__, __FUNCTION__)
@@ -74,7 +77,7 @@ d_char *xs_list_pop(d_char *list, char **data);
74int xs_list_in(char *list, const char *val); 77int xs_list_in(char *list, const char *val);
75d_char *xs_join(char *list, const char *sep); 78d_char *xs_join(char *list, const char *sep);
76d_char *xs_split_n(const char *str, const char *sep, int times); 79d_char *xs_split_n(const char *str, const char *sep, int times);
77#define xs_split(str, sep) xs_split_n(str, sep, 0xfffffff) 80#define xs_split(str, sep) xs_split_n(str, sep, XS_ALL)
78d_char *xs_dict_new(void); 81d_char *xs_dict_new(void);
79d_char *xs_dict_append_m(d_char *dict, const char *key, const char *mem, int dsz); 82d_char *xs_dict_append_m(d_char *dict, const char *key, const char *mem, int dsz);
80#define xs_dict_append(dict, key, data) xs_dict_append_m(dict, key, data, xs_size(data)) 83#define xs_dict_append(dict, key, data) xs_dict_append_m(dict, key, data, xs_size(data))