# HG changeset patch # User Olaf Wintermann # Date 1668944624 -3600 # Node ID 545010bc5e7114916cc534c031eb952008782c65 # Parent 1260fad21be7f4cecbc0b2e03aa3c49fe245a183 replace linkedlist with arraylist in the expression parser diff -r 1260fad21be7 -r 545010bc5e71 src/server/util/object.c --- a/src/server/util/object.c Sun Nov 20 12:19:09 2022 +0100 +++ b/src/server/util/object.c Sun Nov 20 12:43:44 2022 +0100 @@ -28,6 +28,7 @@ #include #include +#include #include #include "../public/nsapi.h" @@ -251,7 +252,7 @@ if(stack->size == 0) { return NULL; } - NSAPIExpression *ret = cxListAt(stack, stack->size-1); + NSAPIExpression *ret = *((NSAPIExpression**)cxListAt(stack, stack->size-1)); cxListRemove(stack, stack->size-1); return ret; } @@ -290,7 +291,7 @@ return 1; // error } - cxListAdd(parser->ex_stack, exp); + cxListAdd(parser->ex_stack, &exp); parser->expect_value = TRUE; parser->expect_arg = FALSE; @@ -309,14 +310,14 @@ exp->value.str = func->identifier; if(parser->ex_stack->size > 0) { - NSAPIExpression *top = cxListAt(parser->ex_stack, parser->ex_stack->size - 1); + NSAPIExpression *top = *((NSAPIExpression**)cxListAt(parser->ex_stack, parser->ex_stack->size - 1)); if(top && top->operator == NSAPI_EXPRESSION_ARG) { exp->left = top; cxListRemove(parser->ex_stack, parser->ex_stack->size - 1); } } - if(cxListAdd(parser->ex_stack, exp)) { + if(cxListAdd(parser->ex_stack, &exp)) { return 1; } parser->expect_value = FALSE; @@ -333,7 +334,7 @@ return 1; } - cxListAdd(parser->ex_stack, exp); + cxListAdd(parser->ex_stack, &exp); if(parser->expect_arg) { ExprOpStackItem argList; argList.expect_value = TRUE; @@ -482,12 +483,13 @@ return NULL; } - return cxListAt(ex_stack, 0); + NSAPIExpression **ret = cxListAt(ex_stack, 0); + return *ret; } NSAPIExpression* expr_parse_logical_expr(pool_handle_t *pool, CxList *tokens, size_t *pos) { - CxList *op_stack = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(ExprOpStackItem)); - CxList *ex_stack = cxPointerLinkedListCreate(pool_allocator(pool), cx_cmp_ptr); + CxList *op_stack = cxArrayListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(ExprOpStackItem), 32); + CxList *ex_stack = cxArrayListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(NSAPIExpression*), 32); ExprParser parser; parser.pool = pool;