X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Farray.c;h=6f9618482bee0a1960ac0e16b622862570b2e634;hb=4191bc604f9c4cbc8be4c41bf94110db565bf86e;hp=c082aba7d8702f341eb585ddc4c8c96637563996;hpb=ab2620a4aef90ff7cf9419abf0a0612339864579;p=libfirm diff --git a/ir/adt/array.c b/ir/adt/array.c index c082aba7d..6f9618482 100644 --- a/ir/adt/array.c +++ b/ir/adt/array.c @@ -11,10 +11,12 @@ */ #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif -#include +#ifdef HAVE_STDLIB_H +# include +#endif #include "array.h" #include "xmalloc.h" @@ -103,10 +105,10 @@ _del_arr_f (void *elts) _arr_descr *dp = _ARR_DESCR (elts); ARR_VRFY (elts); - assert (dp->cookie == ARR_F_MAGIC); + assert (dp->magic == ARR_F_MAGIC); #ifndef NDEBUG - dp->cookie = 0xdeadbeef; + dp->magic = 0xdeadbeef; #endif free (dp); } @@ -128,7 +130,7 @@ _arr_setlen (void *elts, int nelts, size_t elts_size) { _arr_descr *dp = _ARR_DESCR (elts); - assert ((dp->cookie == ARR_F_MAGIC) && (nelts >= 0)); + assert ((dp->magic == ARR_F_MAGIC) && (nelts >= 0)); ARR_VRFY (elts); assert (!dp->eltsize || !nelts || (dp->eltsize == elts_size/nelts)); @@ -142,9 +144,9 @@ _arr_setlen (void *elts, int nelts, size_t elts_size) * Resize a flexible array, allocate more data if needed but do NOT * reduce. * - * @param elts The flexible array (pointer to the first element). - * @param nelts The new number of elements. - * @param elts_size The size of the array elements. + * @param elts The flexible array (pointer to the first element). + * @param nelts The new number of elements. + * @param eltsize The size of the array elements. * * @return A resized flexible array, possibly other address than * elts. @@ -157,7 +159,7 @@ _arr_resize (void *elts, int nelts, size_t eltsize) _arr_descr *dp = _ARR_DESCR (elts); int n; - assert ((dp->cookie == ARR_F_MAGIC) && (nelts >= 0)); + assert ((dp->magic == ARR_F_MAGIC) && (nelts >= 0)); ARR_VRFY (elts); assert (dp->eltsize ? dp->eltsize == eltsize : (dp->eltsize = eltsize, 1)); @@ -179,3 +181,25 @@ _arr_resize (void *elts, int nelts, size_t eltsize) return dp->v.elts; } + +#ifdef DEBUG_libfirm +/** + * This function returns the length of a flexible array. + * Do NOT use is in code, use ARR_LEN() macro! + * This function is intended to be called from a debugger. + */ +int array_len(void *arr) { + return ARR_LEN(arr); +} + +/** + * This function returns the array descriptor of a flexible array. + * Do NOT use is in code!. + * This function is intended to be called from a debugger. + */ +_arr_descr *array_descr(void *arr) { + if (! arr) + return NULL; + return _ARR_DESCR(arr); +} +#endif /* DEBUG_libfirm */