40 while (list[i] != NULL)
51 return list == NULL || list[0] == NULL;
64 for (
size_t i = 0; list[i] != NULL; i++) {
81 new_list[length] = obj;
82 new_list[length + 1] = NULL;
97 new_list[len - 1] = NULL;
116 for (
size_t i = 0; i < len; i++) {
117 if (list[i] != obj) {
118 new_list[index++] = list[i];
121 new_list[index] = NULL;
140 for (
size_t i = 0; i < len; i++) {
142 new_list[new_idx++] = list[i];
145 new_list[new_idx] = NULL;
164 for (
size_t i = 0; i < idx; i++) {
165 new_list[i] = list[i];
167 new_list[idx] = value;
168 for (
size_t i = idx; i < len; i++) {
169 new_list[i + 1] = list[i];
171 new_list[len + 1] = NULL;
185 for (
size_t i = 0; list[i] != NULL; i++) {
186 if (list[i] == value)
232#define gm_ptr_list_for_each(item, list) \
233 for (size_t i = 0; (list != NULL) && (item = list[i]) != NULL; i++)
252static inline size_t gm_bodies_length(
gmBodies list) {
260static inline int gm_bodies_is_empty(
gmBodies list) {
354static inline void gm_bodies_clear(
gmBodies list) {
363#define gm_bodies_for_each(item, list) \
364 for (size_t i = 0; (list != NULL) && (item = list[i]) != NULL; i++)
gmPtrList gm_ptr_list_pop_at(gmPtrList list, size_t idx)
Removes an element at a specific index.
Definition body_list.h:133
gmPtrList gm_ptr_list_insert_at(gmPtrList list, size_t idx, void *value)
Inserts a pointer at a specific index.
Definition body_list.h:158
void * gm_ptr_list_last(gmPtrList list)
Retrieves the last element of the list.
Definition body_list.h:211
gmPtrList gm_ptr_list_push(gmPtrList list, void *obj)
Adds a pointer to the end of the list.
Definition body_list.h:78
void ** gmPtrList
A dynamic, NULL-terminated array of generic void* pointers.
Definition body_list.h:29
size_t gm_ptr_list_length(gmPtrList list)
Calculates the number of elements in a pointer list.
Definition body_list.h:36
gmPtrList gm_ptr_list_pop(gmPtrList list)
Removes the last element from the list.
Definition body_list.h:92
void gm_ptr_list_clear(gmPtrList list)
Frees the memory used by the list.
Definition body_list.h:221
gmPtrList gm_ptr_list_remove(gmPtrList list, void *obj)
Removes all occurrences of a specific pointer from the list.
Definition body_list.h:108
int gm_ptr_list_is_empty(gmPtrList list)
Checks if a pointer list is empty.
Definition body_list.h:50
gmBody ** gmBodies
A specialized dynamic, NULL-terminated list for gmBody pointers.
Definition body_list.h:245
int gm_ptr_list_find(gmPtrList list, void *value)
Finds the index of a specific pointer.
Definition body_list.h:182
size_t gm_ptr_list_count(gmPtrList list, void *obj)
Counts the occurrences of a specific pointer in the list.
Definition body_list.h:60
void * gm_ptr_list_get(gmPtrList list, size_t index)
Retrieves the element at a specific index.
Definition body_list.h:199
void * malloc(size_t size)
Custom implementation of malloc using a static memory pool.
Definition malloc.h:144
void * realloc(void *ptr, size_t size)
Custom implementation of realloc for memory allocated by malloc (this custom version).
Definition malloc.h:236
void free(void *ptr)
Custom implementation of free for memory allocated by malloc (this custom version).
Definition malloc.h:189
Structure representing a physics body with properties for collision and movement.
Definition body.h:25