X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Farray.c;h=c082aba7d8702f341eb585ddc4c8c96637563996;hb=ab2620a4aef90ff7cf9419abf0a0612339864579;hp=b73eac2cafab79163354bca7946cf397d2e5fe6e;hpb=fbcb96cc20a7b5d06136e4c70870e86173e658eb;p=libfirm diff --git a/ir/adt/array.c b/ir/adt/array.c index b73eac2ca..c082aba7d 100644 --- a/ir/adt/array.c +++ b/ir/adt/array.c @@ -32,12 +32,27 @@ # define MIN(a,b) ((a) > (b) ? (b) : (a)) #endif +/** + * An empty dynamic array + */ _arr_descr arr_mt_descr #ifndef NDEBUG = { ARR_D_MAGIC } #endif ; +/** + * Creates a dynamic array on a obstack. + * + * @param obstack An struct obstack * were the data will be allocated + * @param nelts The number of elements + * @param elts_size The size of the array elements. + * + * @return A pointer to the dynamic array (can be used as a pointer to the + * first element of this array). + * + * @remark Helper function, use NEW_ARR_D() instead. + */ void * _new_arr_d (struct obstack *obstack, int nelts, size_t elts_size) { @@ -52,7 +67,17 @@ _new_arr_d (struct obstack *obstack, int nelts, size_t elts_size) return new->v.elts; } - +/** + * Creates a flexible array. + * + * @param nelts The number of elements + * @param elts_size The size of the array elements. + * + * @return A pointer to the flexible array (can be used as a pointer to the + * first element of this array). + * + * @remark Helper function, use NEW_ARR_F() instead. + */ void * _new_arr_f (int nelts, size_t elts_size) { @@ -65,7 +90,13 @@ _new_arr_f (int nelts, size_t elts_size) return new->v.elts; } - +/** + * Delete a flexible array. + * + * @param elts The flexible array (pointer to the first element). + * + * @remark Helper function, use DEL_ARR_F() instead. + */ void _del_arr_f (void *elts) { @@ -80,7 +111,18 @@ _del_arr_f (void *elts) free (dp); } - +/** + * Resize a flexible array, always reallocate data. + * + * @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. + * + * @return A resized flexible array, possibly other address than + * elts. + * + * @remark Helper function, use ARR_SETLEN() instead. + */ void * _arr_setlen (void *elts, int nelts, size_t elts_size) { @@ -96,7 +138,19 @@ _arr_setlen (void *elts, int nelts, size_t elts_size) return dp->v.elts; } -\ +/** + * 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. + * + * @return A resized flexible array, possibly other address than + * elts. + * + * @remark Helper function, use ARR_RESIZE() instead. + */ void * _arr_resize (void *elts, int nelts, size_t eltsize) {