--- libaitio/inc/aitio.h 2012/03/27 21:37:56 1.15.2.2 +++ libaitio/inc/aitio.h 2012/03/27 22:31:37 1.15.2.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitio.h,v 1.15.2.2 2012/03/27 21:37:56 misho Exp $ +* $Id: aitio.h,v 1.15.2.3 2012/03/27 22:31:37 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -140,7 +140,7 @@ typedef struct { #define AIT_GET_F32(_vl) (assert((_vl)), assert(AIT_TYPE((_vl)) == f32), (_vl)->val.f32) #define AIT_GET_F64(_vl) (assert((_vl)), assert(AIT_TYPE((_vl)) == f64), (_vl)->val.f64) -#define AIT_SET_DATA(_vl, _p, _len) do { ait_val_t *__val = (_vl); assert(__val); \ +#define AIT_SET_DATA(_vl, _p, _len) do { ait_val_t *__val = (_vl); \ __val = realloc(__val, sizeof(ait_val_t) + _len); \ if (__val) { \ __val->val_type = data; AIT_LEN(__val) = _len; \ @@ -213,6 +213,10 @@ typedef struct { /* if attribute zeroCopy is set not execute free() */ #define AIT_FREE_VAL(_vl) do { ait_val_t *__val = (_vl); assert(__val); \ + if (AIT_TYPE(__val) == data) { \ + free(__val); \ + break; \ + } \ switch (AIT_TYPE(__val)) { \ case buffer: \ if (__val->val.buffer) { \ @@ -226,16 +230,11 @@ typedef struct { __val->val.string = NULL; \ } \ break; \ - case data: \ - __val = realloc(__val, sizeof(ait_val_t)); \ - break; \ default: \ break; \ } \ - if (__val) { \ - __val->val_type = empty; \ - AIT_LEN(__val) = 0; \ - } \ + __val->val_type = empty; \ + AIT_LEN(__val) = 0; \ } while (0) struct io_ether_addr {