mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Backport from xs.
This commit is contained in:
parent
883902c322
commit
f7781d3f64
2 changed files with 18 additions and 4 deletions
20
xs.h
20
xs.h
|
@ -34,9 +34,7 @@ typedef char d_char;
|
||||||
/* auto-destroyable strings */
|
/* auto-destroyable strings */
|
||||||
#define xs __attribute__ ((__cleanup__ (_xs_destroy))) d_char
|
#define xs __attribute__ ((__cleanup__ (_xs_destroy))) d_char
|
||||||
|
|
||||||
#define _XS_BLK_SIZE 16
|
int _xs_blk_size(int sz);
|
||||||
#define _xs_blk_size(sz) ((((sz) + _XS_BLK_SIZE) / _XS_BLK_SIZE) * _XS_BLK_SIZE)
|
|
||||||
|
|
||||||
void _xs_destroy(char **var);
|
void _xs_destroy(char **var);
|
||||||
#define xs_debug() raise(SIGTRAP)
|
#define xs_debug() raise(SIGTRAP)
|
||||||
xstype xs_type(const char *data);
|
xstype xs_type(const char *data);
|
||||||
|
@ -97,6 +95,22 @@ void _xs_destroy(char **var)
|
||||||
free(*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)
|
xstype xs_type(const char *data)
|
||||||
/* return the type of data */
|
/* return the type of data */
|
||||||
{
|
{
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
/* bb26cbfdc4140e87739b15cfceeafa2e0305bf5e */
|
/* 9f90d5958755ec33c6c4946427f71de37af7500e */
|
||||||
|
|
Loading…
Reference in a new issue