mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-05 00:21:29 +00:00
317a1c91d4
Long term project: convert core to C++ so that we can use higer-level constructs, notably std::vector<>. This does not change any code - only fixes compile issues. Mostly casting of (void *) to the proper type. Also designated initialization of the sample struct had to be rearranged. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
29 lines
1 KiB
C
29 lines
1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef STRUCTURED_LIST_H
|
|
#define STRUCTURED_LIST_H
|
|
|
|
/* Clear whole list; this works for taglist and dive computers */
|
|
#define STRUCTURED_LIST_FREE(_type, _start, _free) \
|
|
{ \
|
|
_type *_ptr = _start; \
|
|
while (_ptr) { \
|
|
_type *_next = _ptr->next; \
|
|
_free(_ptr); \
|
|
_ptr = _next; \
|
|
} \
|
|
}
|
|
|
|
#define STRUCTURED_LIST_COPY(_type, _first, _dest, _cpy) \
|
|
{ \
|
|
_type *_sptr = _first; \
|
|
_type **_dptr = &_dest; \
|
|
while (_sptr) { \
|
|
*_dptr = (_type *)malloc(sizeof(_type)); \
|
|
_cpy(_sptr, *_dptr); \
|
|
_sptr = _sptr->next; \
|
|
_dptr = &(*_dptr)->next; \
|
|
} \
|
|
*_dptr = 0; \
|
|
}
|
|
|
|
#endif
|