| 1 | /* File: universal_arena_list.h; Copyright and License: see below */ |
| 2 | |
| 3 | #ifndef UNIVERSAL_ARENA_LIST_H |
| 4 | #define UNIVERSAL_ARENA_LIST_H |
| 5 | |
| 6 | /* public file for the doxygen documentation: */ |
| 7 | /*! |
| 8 | * \file |
| 9 | * \brief implements a single linked list for use in a memory region. |
| 10 | */ |
| 11 | |
| 12 | #include "u8arena/universal_arena_list_element.h" |
| 13 | #include "u8arena/universal_memory_arena.h" |
| 14 | #include "u8/u8_error.h" |
| 15 | |
| 16 | /*! |
| 17 | * \brief attributes of the universal_arena_list |
| 18 | */ |
| 19 | struct universal_arena_list_struct { |
| 20 | universal_arena_list_element_t *begin; /*!< first element of the single-linked list or NULL if empty */ |
| 21 | universal_memory_arena_t *allocator; /*!< allocator where append allocates memory from */ |
| 22 | }; |
| 23 | |
| 24 | typedef struct universal_arena_list_struct universal_arena_list_t; |
| 25 | |
| 26 | /*! |
| 27 | * \brief initializes the universal_arena_list_t |
| 28 | * |
| 29 | * \param this_ pointer to own object attributes |
| 30 | * \param allocator allocator where universal_arena_list_append allocates memory from |
| 31 | */ |
| 32 | static inline void universal_arena_list_init ( universal_arena_list_t *this_, universal_memory_arena_t *allocator ); |
| 33 | |
| 34 | /*! |
| 35 | * \brief destroys the universal_arena_list_t |
| 36 | * |
| 37 | * \param this_ pointer to own object attributes |
| 38 | */ |
| 39 | static inline void universal_arena_list_destroy ( universal_arena_list_t *this_ ); |
| 40 | |
| 41 | /*! |
| 42 | * \brief appends a pointer to an element to the universal_arena_list_t |
| 43 | * |
| 44 | * \param this_ pointer to own object attributes |
| 45 | * \param element pointer to the element to be appended. Only a valid object can be added, NULL is not allowed. |
| 46 | * \return U8_ERROR_ARRAY_BUFFER_EXCEEDED in case of out of memory, U8_ERROR_NONE in case of success |
| 47 | */ |
| 48 | static inline u8_error_t universal_arena_list_append ( universal_arena_list_t *this_, void* element ); |
| 49 | |
| 50 | /*! |
| 51 | * \brief gets the begin of universal_arena_list_t |
| 52 | * |
| 53 | * \param this_ pointer to own object attributes |
| 54 | * \return pointer to the first element or NULL if empty |
| 55 | */ |
| 56 | static inline universal_arena_list_element_t* universal_arena_list_get_begin ( universal_arena_list_t *this_ ); |
| 57 | |
| 58 | /*! |
| 59 | * \brief gets NULL; for usage in an iterator-like way "for it=begin, it!=end, it=it.next" |
| 60 | * |
| 61 | * \param this_ pointer to own object attributes |
| 62 | * \return always NULL |
| 63 | */ |
| 64 | static inline universal_arena_list_element_t* universal_arena_list_get_end ( universal_arena_list_t *this_ ); |
| 65 | |
| 66 | #include "u8arena/universal_arena_list.inl" |
| 67 | |
| 68 | #endif /* UNIVERSAL_ARENA_LIST_H */ |
| 69 | |
| 70 | |
| 71 | /* |
| 72 | Copyright 2021-2026 Andreas Warnke |
| 73 | |
| 74 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 75 | you may not use this file except in compliance with the License. |
| 76 | You may obtain a copy of the License at |
| 77 | |
| 78 | http://www.apache.org/licenses/LICENSE-2.0 |
| 79 | |
| 80 | Unless required by applicable law or agreed to in writing, software |
| 81 | distributed under the License is distributed on an "AS IS" BASIS, |
| 82 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 83 | See the License for the specific language governing permissions and |
| 84 | limitations under the License. |
| 85 | */ |