--- libelwix/inc/elwix/aarray.h 2019/09/24 15:49:52 1.11 +++ libelwix/inc/elwix/aarray.h 2024/10/29 01:12:06 1.11.44.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aarray.h,v 1.11 2019/09/24 15:49:52 misho Exp $ +* $Id: aarray.h,v 1.11.44.1 2024/10/29 01:12:06 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2019 +Copyright 2004 - 2024 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -53,15 +53,16 @@ typedef struct _tagArray { void **arr_data; } array_t; +#define array_Data(_arr) ((_arr) ? (_arr)->arr_data : NULL) #define array_Size(_arr) ((_arr) ? (_arr)->arr_num : 0) #define array_Last(_arr) (array_Size((_arr)) ? (_arr)->arr_last : -1) #define array_Zero(_arr) (assert((_arr)), (_arr)->arr_last = -1, \ memset((_arr)->arr_data, 0, array_Size((_arr)) * sizeof(intptr_t))) -#define array_Ptr(_arr, _d) ((_arr) ? (_arr)->arr_data[_d] : NULL) +#define array_Ptr(_arr, _d) ((_arr && (_arr)->arr_data) ? (_arr)->arr_data[_d] : NULL) #define array_Get2(_arr, _d) (assert((_arr) && (_arr)->arr_num > _d), ((_arr)->arr_data + _d)) -#define array_Get(_arr, _d) (assert((_arr)), (_arr)->arr_data[_d]) -#define array(_arr, _d, _type) (assert((_arr)), ((_type) (_arr)->arr_data[_d])) +#define array_Get(_arr, _d) (assert((_arr) && (_arr)->arr_data), (_arr)->arr_data[_d]) +#define array(_arr, _d, _type) (assert((_arr) && (_arr)->arr_data), ((_type) (_arr)->arr_data[_d])) #define array_Set(_arr, _d, _ptr) do { int __d = _d; assert((_arr) && (_arr)->arr_num > __d); \ if ((_arr)->arr_last < __d) \ (_arr)->arr_last = __d; \