+/* record a change that was done to a package */
+static void
+uci_add_history(struct uci_context *ctx, struct uci_list *list, int cmd, char *section, char *option, char *value)
+{
+ struct uci_history *h;
+ int size = strlen(section) + 1;
+ char *ptr;
+
+ if (value)
+ size += strlen(value) + 1;
+
+ h = uci_alloc_element(ctx, history, option, size);
+ ptr = uci_dataptr(h);
+ h->cmd = cmd;
+ h->section = strcpy(ptr, section);
+ if (value) {
+ ptr += strlen(ptr) + 1;
+ h->value = strcpy(ptr, value);
+ }
+ uci_list_add(list, &h->e.list);
+}
+
+static void
+uci_free_history(struct uci_history *h)
+{
+ if (!h)
+ return;
+ if ((h->section != NULL) &&
+ (h->section != uci_dataptr(h))) {
+ free(h->section);
+ free(h->value);
+ }
+ uci_free_element(&h->e);
+}
+
+