summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2022-10-22 05:59:55 +0200
committerGravatar default2022-10-22 05:59:55 +0200
commitf7781d3f64e2451383aab27293c96af53ba65145 (patch)
tree10fe77c9131e4c0e0abfcba37288b0c5466b492e
parentBackport from xs. (diff)
downloadpenes-snac2-f7781d3f64e2451383aab27293c96af53ba65145.tar.gz
penes-snac2-f7781d3f64e2451383aab27293c96af53ba65145.tar.xz
penes-snac2-f7781d3f64e2451383aab27293c96af53ba65145.zip
Backport from xs.
-rw-r--r--xs.h20
-rw-r--r--xs_version.h2
2 files changed, 18 insertions, 4 deletions
diff --git a/xs.h b/xs.h
index 0a65774..d30b26f 100644
--- a/xs.h
+++ b/xs.h
@@ -34,9 +34,7 @@ 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#define _XS_BLK_SIZE 16 37int _xs_blk_size(int sz);
38#define _xs_blk_size(sz) ((((sz) + _XS_BLK_SIZE) / _XS_BLK_SIZE) * _XS_BLK_SIZE)
39
40void _xs_destroy(char **var); 38void _xs_destroy(char **var);
41#define xs_debug() raise(SIGTRAP) 39#define xs_debug() raise(SIGTRAP)
42xstype xs_type(const char *data); 40xstype xs_type(const char *data);
@@ -97,6 +95,22 @@ void _xs_destroy(char **var)
97 free(*var); 95 free(*var);
98} 96}
99 97
98
99int _xs_blk_size(int sz)
100/* calculates the block size */
101{
102 int blk_size = 4096;
103
104 if (sz < 256)
105 blk_size = 32;
106 else
107 if (sz < 4096)
108 blk_size = 256;
109
110 return ((((sz) + blk_size) / blk_size) * blk_size);
111}
112
113
100xstype xs_type(const char *data) 114xstype xs_type(const char *data)
101/* return the type of data */ 115/* return the type of data */
102{ 116{
diff --git a/xs_version.h b/xs_version.h
index ab2628c..300ab44 100644
--- a/xs_version.h
+++ b/xs_version.h
@@ -1 +1 @@
/* bb26cbfdc4140e87739b15cfceeafa2e0305bf5e */ /* 9f90d5958755ec33c6c4946427f71de37af7500e */