diff options
author | default <nobody@localhost> | 2022-10-22 05:59:55 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-10-22 05:59:55 +0200 |
commit | f7781d3f64e2451383aab27293c96af53ba65145 (patch) | |
tree | 10fe77c9131e4c0e0abfcba37288b0c5466b492e | |
parent | 883902c322679c73e7edd8347139c6ecad4a7127 (diff) |
Backport from xs.
-rw-r--r-- | xs.h | 20 | ||||
-rw-r--r-- | xs_version.h | 2 |
2 files changed, 18 insertions, 4 deletions
@@ -34,9 +34,7 @@ typedef char d_char; /* auto-destroyable strings */ #define xs __attribute__ ((__cleanup__ (_xs_destroy))) d_char -#define _XS_BLK_SIZE 16 -#define _xs_blk_size(sz) ((((sz) + _XS_BLK_SIZE) / _XS_BLK_SIZE) * _XS_BLK_SIZE) - +int _xs_blk_size(int sz); void _xs_destroy(char **var); #define xs_debug() raise(SIGTRAP) xstype xs_type(const char *data); @@ -97,6 +95,22 @@ void _xs_destroy(char **var) free(*var); } + +int _xs_blk_size(int sz) +/* calculates the block size */ +{ + int blk_size = 4096; + + if (sz < 256) + blk_size = 32; + else + if (sz < 4096) + blk_size = 256; + + return ((((sz) + blk_size) / blk_size) * blk_size); +} + + xstype xs_type(const char *data) /* return the type of data */ { 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 */ |