From c57cfea7f793b2b1fadf68cc676fb917b7df1c7f Mon Sep 17 00:00:00 2001 From: Ulysse Cura Date: Mon, 10 Aug 2026 00:47:04 +0200 Subject: [PATCH] Removed useless code. --- src/asset_manager.c | 6 ------ src/ecs.c | 27 +++------------------------ src/headers/linked_list.h | 2 +- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/asset_manager.c b/src/asset_manager.c index df8412c..88638b6 100644 --- a/src/asset_manager.c +++ b/src/asset_manager.c @@ -10,12 +10,6 @@ int create_asset(asset_t *asset, va_list args) { - if(!asset) - { - error_printf("Failed to allocate memory : %d", errno); - return EXIT_FAILURE; - } - asset->type = va_arg(args, asset_type_t); asset->nb_refs = 0; diff --git a/src/ecs.c b/src/ecs.c index c64f32a..3303add 100644 --- a/src/ecs.c +++ b/src/ecs.c @@ -6,12 +6,6 @@ int create_component(component_t *component, va_list args) { - if(!component) - { - error_printf("Component cannot be NULL"); - return EXIT_FAILURE; - } - component->type = va_arg(args, component_type_t); switch(component->type) @@ -41,12 +35,6 @@ int create_component(component_t *component, va_list args) inline int destroy_component(component_t *component) { - if(!component) - { - error_printf("Component cannot be NULL"); - return EXIT_FAILURE; - } - if(component->deleter(component)) return EXIT_FAILURE; return EXIT_SUCCESS; @@ -54,12 +42,6 @@ inline int destroy_component(component_t *component) int create_entity(entity_t *entity, va_list args) { - if(!entity) - { - error_printf("Entity cannot be NULL"); - return EXIT_FAILURE; - } - entity->id = va_arg(args, size_t); entity->draw_priority = 0; @@ -70,12 +52,6 @@ int create_entity(entity_t *entity, va_list args) inline int destroy_entity(entity_t *entity) { - if(!entity) - { - error_printf("Entity cannot be NULL"); - return EXIT_FAILURE; - } - if(linked_list_exit(&entity->components)) return EXIT_FAILURE; return EXIT_SUCCESS; @@ -85,6 +61,7 @@ component_t *entity_new_component(entity_t *entity, component_type_t component_t { elem_t *component_elem = create_elem(&entity->components, component_type); if(!component_elem) return NULL; + component_t *component = component_elem->data; component->entity = entity; @@ -118,6 +95,7 @@ inline component_t *entity_get_component(const entity_t *entity, component_type_ static inline int action_update_component(elem_t *elem, va_list args __attribute__((unused))) { component_t *component = elem->data; + if(component->update(component)) return EXIT_FAILURE; return EXIT_SUCCESS; @@ -135,6 +113,7 @@ inline int update_entity(entity_t *entity) static inline int action_draw_component(elem_t *elem, va_list args __attribute__((unused))) { component_t *component = elem->data; + if(component->draw) if(component->draw(component)) return EXIT_FAILURE; return EXIT_SUCCESS; diff --git a/src/headers/linked_list.h b/src/headers/linked_list.h index 030342b..9e02f6e 100644 --- a/src/headers/linked_list.h +++ b/src/headers/linked_list.h @@ -258,7 +258,7 @@ elem_t *linked_list_get_if(const linked_list_t *linked_list, const condition_t c * @param condition Condition to verify * @param ... Argument to pass to the condition * - * @return Pointer to element, NULL if no element verify the condition or if an error occurred. + * @return EXIT_SUCCESS, EXIT_FAILURE on error. */ int linked_list_remove_if(linked_list_t *linked_list, const condition_t condition, ...);