diff options
| author | 2022-10-22 05:59:55 +0200 | |
|---|---|---|
| committer | 2022-10-22 05:59:55 +0200 | |
| commit | f7781d3f64e2451383aab27293c96af53ba65145 (patch) | |
| tree | 10fe77c9131e4c0e0abfcba37288b0c5466b492e | |
| parent | Backport from xs. (diff) | |
| download | penes-snac2-f7781d3f64e2451383aab27293c96af53ba65145.tar.gz penes-snac2-f7781d3f64e2451383aab27293c96af53ba65145.tar.xz penes-snac2-f7781d3f64e2451383aab27293c96af53ba65145.zip | |
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; | |||
| 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 | 37 | int _xs_blk_size(int sz); |
| 38 | #define _xs_blk_size(sz) ((((sz) + _XS_BLK_SIZE) / _XS_BLK_SIZE) * _XS_BLK_SIZE) | ||
| 39 | |||
| 40 | void _xs_destroy(char **var); | 38 | void _xs_destroy(char **var); |
| 41 | #define xs_debug() raise(SIGTRAP) | 39 | #define xs_debug() raise(SIGTRAP) |
| 42 | xstype xs_type(const char *data); | 40 | xstype 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 | |||
| 99 | int _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 | |||
| 100 | xstype xs_type(const char *data) | 114 | xstype 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 */ | ||