src/basic/static-destruct.c
raw| 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 | |
| 3 | #include "static-destruct.h" |
| 4 | |
| 5 | void static_destruct_impl(const StaticDestructor *start, const StaticDestructor *end) { |
| 6 | if (!start) |
| 7 | return; |
| 8 | |
| 9 | for (const StaticDestructor *d = start; d < end; d++) |
| 10 | switch (d->type) { |
| 11 | case STATIC_DESTRUCTOR_SIMPLE: |
| 12 | d->simple.destroy(d->simple.data); |
| 13 | break; |
| 14 | |
| 15 | case STATIC_DESTRUCTOR_ARRAY: |
| 16 | array_cleanup(&d->array); |
| 17 | break; |
| 18 | |
| 19 | default: |
| 20 | assert_not_reached(); |
| 21 | } |
| 22 | } |