diff options
Diffstat (limited to 'src/ucl/include/ucl.h')
-rw-r--r-- | src/ucl/include/ucl.h | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/ucl/include/ucl.h b/src/ucl/include/ucl.h index d1dd61fdb..929812670 100644 --- a/src/ucl/include/ucl.h +++ b/src/ucl/include/ucl.h @@ -24,8 +24,14 @@ #ifndef UCL_H_ #define UCL_H_ -#include "config.h" +#include <string.h> +#include <stddef.h> +#include <stdlib.h> +#include <stdint.h> #include <stdbool.h> +#include <stdarg.h> +#include <stdio.h> +#include "config.h" /** * @mainpage @@ -372,7 +378,7 @@ ucl_object_t* ucl_object_insert_key_merged (ucl_object_t *top, ucl_object_t *elt /** * Append an element to the array object * @param top destination object (will be created automatically if top is NULL) - * @param eltelement to append (must NOT be NULL) + * @param elt element to append (must NOT be NULL) * @return new value of top object */ static inline ucl_object_t * ucl_array_append (ucl_object_t *top, @@ -387,18 +393,25 @@ ucl_array_append (ucl_object_t *top, ucl_object_t *elt) } if (top == NULL) { - top = ucl_object_new (); - top->type = UCL_ARRAY; + top = ucl_object_typed_new (UCL_ARRAY); top->value.av = elt; elt->next = NULL; elt->prev = elt; + top->len = 1; } else { head = top->value.av; - elt->prev = head->prev; - head->prev->next = elt; - head->prev = elt; + if (head == NULL) { + top->value.av = elt; + elt->prev = elt; + } + else { + elt->prev = head->prev; + head->prev->next = elt; + head->prev = elt; + } elt->next = NULL; + top->len ++; } return top; |