Changeset d011038 in mainline for uspace/lib/c/include/adt/generic_field.h
- Timestamp:
- 2011-03-29T20:12:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8f17503
- Parents:
- c4fb95d3 (diff), 93ebe4e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/generic_field.h
rc4fb95d3 rd011038 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 48 52 /** Generic type field declaration. 49 53 * … … 63 67 int name##_add(name##_t *, type *); \ 64 68 int name##_count(name##_t *); \ 65 void name##_destroy(name##_t * ); \66 void name##_exclude_index(name##_t *, int ); \69 void name##_destroy(name##_t *, DTOR_T()); \ 70 void name##_exclude_index(name##_t *, int, DTOR_T()); \ 67 71 type **name##_get_field(name##_t *); \ 68 72 type *name##_get_index(name##_t *, int); \ … … 103 107 } \ 104 108 \ 105 void name##_destroy(name##_t *field ) \109 void name##_destroy(name##_t *field, DTOR_T(dtor)) \ 106 110 { \ 107 111 if (name##_is_valid(field)) { \ 108 112 int index; \ 109 113 field->magic = 0; \ 110 for (index = 0; index < field->next; index++) { \ 111 if (field->items[index]) \ 112 free(field->items[index]); \ 114 if (dtor) { \ 115 for (index = 0; index < field->next; index++) { \ 116 if (field->items[index]) \ 117 dtor(field->items[index]); \ 118 } \ 113 119 } \ 114 120 free(field->items); \ … … 116 122 } \ 117 123 \ 118 void name##_exclude_index(name##_t *field, int index ) \124 void name##_exclude_index(name##_t *field, int index, DTOR_T(dtor)) \ 119 125 { \ 120 126 if (name##_is_valid(field) && (index >= 0) && \ 121 127 (index < field->next) && (field->items[index])) { \ 122 free(field->items[index]); \ 128 if (dtor) \ 129 dtor(field->items[index]); \ 123 130 field->items[index] = NULL; \ 124 131 } \
Note:
See TracChangeset
for help on using the changeset viewer.