Changes in uspace/lib/c/include/adt/generic_field.h [5fe7692:442ebbe] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/generic_field.h
r5fe7692 r442ebbe 46 46 #define GENERIC_FIELD_MAGIC_VALUE 0x55667788 47 47 48 /** Generic destructor function pointer. */49 #define DTOR_T(identifier) \50 void (*identifier)(const void *)51 52 48 /** Generic type field declaration. 53 49 * … … 67 63 int name##_add(name##_t *, type *); \ 68 64 int name##_count(name##_t *); \ 69 void name##_destroy(name##_t * , DTOR_T()); \70 void name##_exclude_index(name##_t *, int , DTOR_T()); \65 void name##_destroy(name##_t *); \ 66 void name##_exclude_index(name##_t *, int); \ 71 67 type **name##_get_field(name##_t *); \ 72 68 type *name##_get_index(name##_t *, int); \ … … 107 103 } \ 108 104 \ 109 void name##_destroy(name##_t *field , DTOR_T(dtor)) \105 void name##_destroy(name##_t *field) \ 110 106 { \ 111 107 if (name##_is_valid(field)) { \ 112 108 int index; \ 113 109 field->magic = 0; \ 114 if (dtor) { \ 115 for (index = 0; index < field->next; index++) { \ 116 if (field->items[index]) \ 117 dtor(field->items[index]); \ 118 } \ 110 for (index = 0; index < field->next; index++) { \ 111 if (field->items[index]) \ 112 free(field->items[index]); \ 119 113 } \ 120 114 free(field->items); \ … … 122 116 } \ 123 117 \ 124 void name##_exclude_index(name##_t *field, int index , DTOR_T(dtor)) \118 void name##_exclude_index(name##_t *field, int index) \ 125 119 { \ 126 120 if (name##_is_valid(field) && (index >= 0) && \ 127 121 (index < field->next) && (field->items[index])) { \ 128 if (dtor) \ 129 dtor(field->items[index]); \ 122 free(field->items[index]); \ 130 123 field->items[index] = NULL; \ 131 124 } \
Note:
See TracChangeset
for help on using the changeset viewer.