]> pilppa.org Git - uci.git/commitdiff
Merge remote branch 'uci_upstream_remote/master' into uci_upstream_merge uci_upstream_merge
authorMika Laitio <lamikr@pilppa.org>
Sun, 30 Jan 2011 12:50:18 +0000 (14:50 +0200)
committerMika Laitio <lamikr@pilppa.org>
Sun, 30 Jan 2011 12:50:18 +0000 (14:50 +0200)
1  2 
file.c
list.c

diff --combined file.c
index 867984120b6c250b71e5a3a3f6436d13568cb71c,5ab50a911a88e9f5cc510d8399b3fb309d6b8569..60946ef7d710cd76ad2aac939cd31ad6ad97a180
--- 1/file.c
--- 2/file.c
+++ b/file.c
@@@ -675,7 -675,7 +675,7 @@@ static char *uci_config_path(struct uci
        return filename;
  }
  
- void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool overwrite)
static void uci_file_commit(struct uci_context *ctx, struct uci_package **package, bool overwrite)
  {
        struct uci_package *p = *package;
        FILE *f = NULL;
@@@ -808,7 -808,7 +808,7 @@@ static char **uci_list_config_files(str
  static struct uci_package *uci_file_load(struct uci_context *ctx, const char *name)
  {
        struct uci_package *package = NULL;
 -      char *filename;
 +      char *filename = NULL;
        bool confdir;
        FILE *file = NULL;
  
  
  done:
        uci_close_stream(file);
 -      if (ctx->err)
 +      if (ctx->err) {
 +              free(filename);
                UCI_THROW(ctx, ctx->err);
 +      }
        return package;
  }
  
diff --combined list.c
index 661ecc6ded8f3a334cae1eeb4ef961d4d550cd27,c8a470055360c6b58592dd82a0d08943fc98e058..31ee551409d34bdb319ddb3234483ad2e5f1ba25
--- 1/list.c
--- 2/list.c
+++ b/list.c
@@@ -19,11 -19,12 +19,12 @@@ static void uci_list_set_pos(struct uci
  
        uci_list_del(ptr);
        uci_foreach_element(head, p) {
-               new_head = &p->list;
                if (pos-- <= 0)
                        break;
+               new_head = &p->list;
        }
-       uci_list_add(new_head, ptr);
+       uci_list_add(new_head->next, ptr);
  }
  
  static inline void uci_list_fixup(struct uci_list *ptr)
@@@ -72,7 -73,8 +73,7 @@@ uci_free_element(struct uci_element *e
        free(e);
  }
  
 -static struct uci_option *
 -uci_alloc_option(struct uci_section *s, const char *name, const char *value)
 +struct uci_option *uci_alloc_option(struct uci_section *s, const char *name, const char *value)
  {
        struct uci_package *p = s->package;
        struct uci_context *ctx = p->ctx;
@@@ -542,22 -544,6 +543,22 @@@ int uci_add_section(struct uci_context 
        return 0;
  }
  
 +int uci_add_named_section(struct uci_context *ctx, struct uci_package *p, const char *type, const char *name, struct uci_section **res)
 +{
 +      bool internal = ctx->internal;
 +      struct uci_section *s;
 +
 +      UCI_HANDLE_ERR(ctx);
 +      UCI_ASSERT(ctx, p != NULL);
 +      s = uci_alloc_section(p, type, name);
 +      uci_fixup_section(ctx, s);
 +      *res = s;
 +      if (!internal && p->has_delta)
 +              uci_add_delta(ctx, &p->delta, UCI_CMD_ADD, s->e.name, NULL, type);
 +
 +      return 0;
 +}
 +
  int uci_delete(struct uci_context *ctx, struct uci_ptr *ptr)
  {
        /* NB: pass on internal flag to uci_del_element */