Index: src/conf.c =================================================================== --- src/conf.c (revision 2266) +++ src/conf.c (revision 2267) @@ -366,12 +366,12 @@ return 0; } -static void conf_insert_arr(conf_native_t *dest) +static void conf_insert_arr(conf_native_t *dest, int offs) { #define CASE_MOVE(typ, fld) \ - case typ: memmove(dest->val.fld+1, dest->val.fld, dest->used * sizeof(dest->val.fld[0])); return + case typ: memmove(dest->val.fld+offs, dest->val.fld, dest->used * sizeof(dest->val.fld[0])); return - memmove(dest->prop+1, dest->prop, dest->used * sizeof(dest->prop[0])); + memmove(dest->prop+offs, dest->prop, dest->used * sizeof(dest->prop[0])); if (dest->used > 0) { switch(dest->type) { CASE_MOVE(CFN_STRING, string); @@ -392,21 +392,29 @@ int conf_merge_patch_array(conf_native_t *dest, lht_node_t *src_lst, int prio, conf_policy_t pol) { lht_node_t *s; - int res, idx, didx; + int res, idx, didx, maxpr; if ((pol == POL_DISABLE) || (pol == POL_invalid)) return 0; + if (pol == POL_PREPEND) { + for(s = src_lst->data.list.first, maxpr = 0; s != NULL; s = s->next, maxpr++) ; + + if (dest->used+maxpr >= dest->array_size) + maxpr = dest->array_size - dest->used - 1; + + conf_insert_arr(dest, maxpr); + dest->used += maxpr; + } +/*printf("arr merge prio: %d\n", prio);*/ for(s = src_lst->data.list.first, idx = 0; s != NULL; s = s->next, idx++) { if (s->type == LHT_TEXT) { switch(pol) { case POL_PREPEND: - if (dest->used < dest->array_size) { - didx = 0; - conf_insert_arr(dest); - } + if (idx < maxpr) + didx = idx; else - didx = dest->array_size+1; /* indicate that array is full */ + didx = dest->array_size+1; /* indicate array full */ break; case POL_APPEND: didx = dest->used++; @@ -416,7 +424,7 @@ break; case POL_DISABLE: case POL_invalid: return 0; /* compiler warning */ } - +/*printf(" didx: %d / %d '%s'\n", didx, dest->array_size, s->data.text.value);*/ if (didx >= dest->array_size) { hid_cfg_error(s, "Array is already full [%d] of [%d] ingored value: '%s' policy=%d\n", dest->used, dest->array_size, s->data.text.value, pol); res = -1;