version 1.16.2.7, 2012/04/05 11:11:48
|
version 1.17.4.9, 2012/05/19 00:07:07
|
Line 74 typedef struct _tagSplitArray {
|
Line 74 typedef struct _tagSplitArray {
|
} sarr_t; |
} sarr_t; |
|
|
typedef struct _tagArray { |
typedef struct _tagArray { |
|
int arr_last; |
int arr_num; |
int arr_num; |
void **arr_data; |
void **arr_data; |
} array_t; |
} array_t; |
Line 118 typedef struct {
|
Line 119 typedef struct {
|
#define AIT_LEN(_vl) (_vl)->val_len |
#define AIT_LEN(_vl) (_vl)->val_len |
#define AIT_KEY(_vl) (_vl)->val_key |
#define AIT_KEY(_vl) (_vl)->val_key |
#define AIT_RAW(_vl) (_vl)->val.net |
#define AIT_RAW(_vl) (_vl)->val.net |
#define AIT_VOID(_vl) (_vl)->val.ptr | #define AIT_ADDR(_vl) (_vl)->val.ptr |
#define AIT_BLOB_CHUNKS(_vl, _n) (AIT_LEN((_vl)) / _n + (AIT_LEN((_vl)) % _n) ? 1 : 0) |
#define AIT_BLOB_CHUNKS(_vl, _n) (AIT_LEN((_vl)) / _n + (AIT_LEN((_vl)) % _n) ? 1 : 0) |
#define AIT_ISEMPTY(_vl) (AIT_TYPE((_vl)) == empty) |
#define AIT_ISEMPTY(_vl) (AIT_TYPE((_vl)) == empty) |
|
|
#define AIT_GET_LIKE(_vl, _type) ((_type) (_vl)->val.ptr) | #define AIT_GET_LIKE(_vl, _type) ((_type) AIT_ADDR((_vl))) |
|
|
#define AIT_GET_PTR(_vl) (assert(AIT_TYPE((_vl)) == ptr), (_vl)->val.ptr) |
#define AIT_GET_PTR(_vl) (assert(AIT_TYPE((_vl)) == ptr), (_vl)->val.ptr) |
#define AIT_GET_DATA(_vl) (assert(AIT_TYPE((_vl)) == data), (_vl)->val_data) |
#define AIT_GET_DATA(_vl) (assert(AIT_TYPE((_vl)) == data), (_vl)->val_data) |
Line 152 typedef struct {
|
Line 153 typedef struct {
|
#define AIT_SET_PTR(_vl, _p, _len) do { ait_val_t *__val = (_vl); assert(__val); \ |
#define AIT_SET_PTR(_vl, _p, _len) do { ait_val_t *__val = (_vl); assert(__val); \ |
__val->val_type = ptr; AIT_LEN(__val) = _len; \ |
__val->val_type = ptr; AIT_LEN(__val) = _len; \ |
__val->val.ptr = _p; } while (0) |
__val->val.ptr = _p; } while (0) |
|
#define AIT_RE_BUF(_vl, _len) do { ait_val_t *__val = (_vl); assert(__val); \ |
|
void *__ptr = realloc(AIT_GET_BUF(__val), _len); \ |
|
if (__ptr) { \ |
|
__val->val.buffer = __ptr; AIT_LEN(__val) = _len; \ |
|
} } while (0) |
|
#define AIT_SET_BUF2(_vl, _c, _len) do { ait_val_t *__val = (_vl); assert(__val); \ |
|
__val->val.buffer = malloc(_len); \ |
|
if (__val->val.buffer) { \ |
|
__val->val_type = buffer; AIT_LEN(__val) = _len; \ |
|
memset(__val->val.buffer, _c, _len); \ |
|
} } while (0) |
#define AIT_SET_BUF(_vl, _v, _len) do { ait_val_t *__val = (_vl); assert(__val); \ |
#define AIT_SET_BUF(_vl, _v, _len) do { ait_val_t *__val = (_vl); assert(__val); \ |
__val->val.buffer = malloc(_len); \ |
__val->val.buffer = malloc(_len); \ |
if (__val->val.buffer) { \ |
if (__val->val.buffer) { \ |
__val->val_type = buffer; AIT_LEN(__val) = _len; \ |
__val->val_type = buffer; AIT_LEN(__val) = _len; \ |
memcpy(__val->val.buffer, (_v), _len); \ | if ((_v)) \ |
| memcpy(__val->val.buffer, (_v), _len); \ |
| else \ |
| memset(__val->val.buffer, 0, _len); \ |
} } while (0) |
} } while (0) |
#define AIT_SET_STR(_vl, _v) do { ait_val_t *__val = (_vl); assert(__val); \ |
#define AIT_SET_STR(_vl, _v) do { ait_val_t *__val = (_vl); assert(__val); \ |
__val->val.string = (int8_t*) strdup((_v)); \ |
__val->val.string = (int8_t*) strdup((_v)); \ |
Line 213 typedef struct {
|
Line 228 typedef struct {
|
__val->val_type = f64; __val->val.f64 = _n; \ |
__val->val_type = f64; __val->val.f64 = _n; \ |
AIT_LEN(__val) = sizeof(double); } while (0) |
AIT_LEN(__val) = sizeof(double); } while (0) |
|
|
|
#define AIT_COPY_VAL(_vl, _v) do { memcpy((_vl), (_v), sizeof(ait_val_t)); \ |
|
switch (AIT_TYPE((_vl))) { \ |
|
case buffer: \ |
|
AIT_SET_BUF((_vl), AIT_GET_BUF((_v)), AIT_LEN((_v))); \ |
|
break; \ |
|
case string: \ |
|
AIT_SET_STR((_vl), AIT_GET_STR((_v))); \ |
|
break; \ |
|
default: \ |
|
break; \ |
|
} \ |
|
} while (0) |
|
#define AIT_COPY_VAL2(_vl, _v) do { AIT_COPY_VAL((_vl), (_v)); \ |
|
if (AIT_TYPE((_vl)) == data) \ |
|
AIT_SET_DATA((_vl), AIT_GET_DATA((_v)), AIT_LEN((_v))); \ |
|
} while (0) |
|
|
|
#define AIT_INIT_VAL(_vl) (memset((_vl), 0, sizeof(ait_val_t))) |
/* if attribute zeroCopy is set not execute free() */ |
/* if attribute zeroCopy is set not execute free() */ |
#define AIT_FREE_VAL(_vl) do { ait_val_t *__val = (_vl); assert(__val); \ |
#define AIT_FREE_VAL(_vl) do { ait_val_t *__val = (_vl); assert(__val); \ |
switch (AIT_TYPE(__val)) { \ |
switch (AIT_TYPE(__val)) { \ |
Line 355 inline ait_val_t *io_allocVar(void);
|
Line 388 inline ait_val_t *io_allocVar(void);
|
* @val = Variable |
* @val = Variable |
* return: none |
* return: none |
*/ |
*/ |
inline void io_freeVar(ait_val_t * __restrict val); | inline void io_freeVar(ait_val_t ** __restrict val); |
/* |
/* |
* io_allocVars() - Allocate ait_val_t array |
* io_allocVars() - Allocate ait_val_t array |
* |
* |
Line 378 inline int io_clrVars(array_t * __restrict vars);
|
Line 411 inline int io_clrVars(array_t * __restrict vars);
|
*/ |
*/ |
inline void io_freeVars(array_t ** __restrict vars); |
inline void io_freeVars(array_t ** __restrict vars); |
/* |
/* |
|
* io_getVars() - Get ait_val_t element from array and if not exists allocate it |
|
* |
|
* @vars = Variable array |
|
* @n = index of variable into array |
|
* return: NULL error or !=NULL ait_val_t element |
|
*/ |
|
inline ait_val_t *io_getVars(array_t ** __restrict vars, int n); |
|
/* |
* io_sortVars() - Sorting array with variables |
* io_sortVars() - Sorting array with variables |
* |
* |
* @vars = Variable array |
* @vars = Variable array |
Line 557 inline char **io_arrayTo(array_t * __restrict arr);
|
Line 598 inline char **io_arrayTo(array_t * __restrict arr);
|
* io_arrayLen() - Get last used element in dynamic array (array Length) |
* io_arrayLen() - Get last used element in dynamic array (array Length) |
* |
* |
* @arr = Array |
* @arr = Array |
* return: -1 error, 0 empty or >0 position of last used element | * return: -1 empty or >-1 position of last used element |
*/ |
*/ |
inline int io_arrayLen(array_t * __restrict arr); |
inline int io_arrayLen(array_t * __restrict arr); |
/* |
/* |
Line 595 int io_arrayGrow(array_t * __restrict arr, int newNumI
|
Line 636 int io_arrayGrow(array_t * __restrict arr, int newNumI
|
int io_arrayVacuum(array_t * __restrict arr, int fromWhere); |
int io_arrayVacuum(array_t * __restrict arr, int fromWhere); |
|
|
#define io_arraySize(_arr) ((_arr) ? (_arr)->arr_num : 0) |
#define io_arraySize(_arr) ((_arr) ? (_arr)->arr_num : 0) |
|
#define io_arrayLast(_arr) (io_arraySize((_arr)) ? (_arr)->arr_last : -1) |
#define io_arrayZero(_arr) (assert((_arr)), memset((_arr)->arr_data, 0, \ |
#define io_arrayZero(_arr) (assert((_arr)), memset((_arr)->arr_data, 0, \ |
io_arraySize((_arr)) * sizeof(void*))) |
io_arraySize((_arr)) * sizeof(void*))) |
|
|
#define io_arrayGet(_arr, _d) (assert((_arr) && (_arr)->arr_num > _d), *((_arr)->arr_data + _d)) | #define io_arrayGet2(_arr, _d) (assert((_arr) && (_arr)->arr_num > _d), ((_arr)->arr_data + _d)) |
| #define io_arrayGet(_arr, _d) (assert((_arr) && (_arr)->arr_num > _d), (_arr)->arr_data[_d]) |
#define io_array(_arr, _d, _type) (assert((_arr) && (_arr)->arr_num > _d), \ |
#define io_array(_arr, _d, _type) (assert((_arr) && (_arr)->arr_num > _d), \ |
((_type) *((_arr)->arr_data + _d))) | ((_type) (_arr)->arr_data[_d])) |
#define io_arraySet(_arr, _d, _ptr) do { \ |
#define io_arraySet(_arr, _d, _ptr) do { \ |
assert((_arr) && (_arr)->arr_num > _d); \ |
assert((_arr) && (_arr)->arr_num > _d); \ |
*((_arr)->arr_data + _d) = (void*) (_ptr); \ | if ((_arr)->arr_last < _d) \ |
| (_arr)->arr_last = _d; \ |
| (_arr)->arr_data[_d] = (void*) (_ptr); \ |
} while (0) |
} while (0) |
#define io_arrayDel(_arr, _d, _fri) do { \ |
#define io_arrayDel(_arr, _d, _fri) do { \ |
assert((_arr) && (_arr)->arr_num > _d); \ |
assert((_arr) && (_arr)->arr_num > _d); \ |
if (_fri) \ | if (_fri && (_arr)->arr_data[_d]) \ |
free(*((_arr)->arr_data + _d)); \ | free((_arr)->arr_data[_d]); \ |
*((_arr)->arr_data + _d) = NULL; \ | (_arr)->arr_data[_d] = NULL; \ |
} while (0) |
} while (0) |
|
|
/* |
/* |
Line 626 inline void *io_arrayElem(array_t * __restrict arr, in
|
Line 671 inline void *io_arrayElem(array_t * __restrict arr, in
|
* |
* |
* @arr = Array |
* @arr = Array |
* @data = Element, if set NULL return only first empty position |
* @data = Element, if set NULL return only first empty position |
|
* @mayGrow = Array may to grow, if not enough room for new element |
* return: -1 not found empty position, array is full!, >-1 return position of stored element into array |
* return: -1 not found empty position, array is full!, >-1 return position of stored element into array |
*/ |
*/ |
inline int io_arrayPush(array_t * __restrict arr, void **data); | inline int io_arrayPush(array_t * __restrict arr, void **data, int mayGrow); |
/* |
/* |
* io_arrayPop() - Pop element from dynamic array like stack manner, last used position |
* io_arrayPop() - Pop element from dynamic array like stack manner, last used position |
* |
* |