version 1.17, 2012/05/14 12:49:21
|
version 1.17.4.3, 2012/05/15 22:20:28
|
Line 123 typedef struct {
|
Line 123 typedef struct {
|
#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) AIT_ADDR(_vl)) | #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 153 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 && (_v)); \ |
__val->val.string = (int8_t*) strdup((_v)); \ |
__val->val.string = (int8_t*) strdup((_v)); \ |
if (__val->val.string) { \ |
if (__val->val.string) { \ |
__val->val_type = string; \ |
__val->val_type = string; \ |
Line 213 typedef struct {
|
Line 227 typedef struct {
|
#define AIT_SET_F64(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ |
#define AIT_SET_F64(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ |
__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))) |
#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() */ |