Diff for /libaitio/inc/aitio.h between versions 1.17 and 1.18

version 1.17, 2012/05/14 12:49:21 version 1.18, 2012/05/19 00:00:12
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 214  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)))  #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); \
Line 380  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 602  int io_arrayVacuum(array_t * __restrict arr, int fromW Line 641  int io_arrayVacuum(array_t * __restrict arr, int fromW
                                                 io_arraySize((_arr)) * sizeof(void*)))                                                  io_arraySize((_arr)) * sizeof(void*)))
   
 #define io_arrayGet2(_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_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); \
                                                 if ((_arr)->arr_last < _d) \                                                  if ((_arr)->arr_last < _d) \
                                                         (_arr)->arr_last = _d; \                                                          (_arr)->arr_last = _d; \
                                                *((_arr)->arr_data + _d) = (void*) (_ptr); \                                                (_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) 
#define io_arraySyncLast(_arr)          do { \ 
                                                assert((_arr)); \ 
                                                (_arr)->arr_last = io_arrayLen((_arr)); \ 
                                         } while (0)                                          } while (0)
   
 /*  /*

Removed from v.1.17  
changed lines
  Added in v.1.18


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>