Sun, 04 May 2025 21:50:13 +0200
use new UCX 3.2 cxListEmplace()
src/behavior.c | file | annotate | diff | comparison | revisions |
--- a/src/behavior.c Sat May 03 19:48:57 2025 +0200 +++ b/src/behavior.c Sun May 04 21:50:13 2025 +0200 @@ -45,20 +45,18 @@ } AscBehavior *asc_behavior_add_impl(AscSceneNode *node, struct asc_behavior_create_args args) { - // TODO: replace cxListAdd() with cxListEmplace() when upgrading to UCX 3.2 - AscBehavior behavior = {0}; - behavior.node = node; - behavior.func = args.func; - behavior.destroy_func = args.destroy_func; - behavior.data = args.data; if (node->behaviors == NULL) { node->behaviors = asc_behavior_new_list(); } - if (cxListAdd(node->behaviors, &behavior)) { + AscBehavior *behavior = cxListEmplace(node->behaviors); + if (behavior == NULL) { // TODO: output ID of node once we have implemented that asc_error("Failed to add behavior to scene node."); return NULL; } - // TODO: replace with cxListLast() when upgrading to UCX 3.2 - return cxListAt(node->behaviors, cxListSize(node->behaviors) - 1); + behavior->node = node; + behavior->func = args.func; + behavior->destroy_func = args.destroy_func; + behavior->data = args.data; + return behavior; }