]> pilppa.org Git - uci.git/blobdiff - ucimap.h
ucimap: add custom free() callbacks for options, only used on custom datatypes
[uci.git] / ucimap.h
index 4f80111622234e1331da5c32db12337216357d3d..2195e78bb3fccc1119881d34c152d474c0ba7a34 100644 (file)
--- a/ucimap.h
+++ b/ucimap.h
@@ -84,6 +84,8 @@
 struct uci_sectionmap;
 struct uci_optmap;
 struct ucimap_list;
+struct uci_alloc;
+struct uci_alloc_custom;
 
 struct uci_map {
        struct uci_sectionmap **sections;
@@ -121,6 +123,7 @@ union ucimap_data {
        bool b;
        char *s;
        void *ptr;
+       void **data;
        struct ucimap_list *list;
 };
 
@@ -132,7 +135,9 @@ struct ucimap_section_data {
 
        /* list of allocations done by ucimap */
        struct uci_alloc *allocmap;
-       unsigned long allocmap_len;
+       struct uci_alloc_custom *alloc_custom;
+       unsigned int allocmap_len;
+       unsigned int alloc_custom_len;
 
        /* map for changed fields */
        unsigned char *cmap;
@@ -181,6 +186,7 @@ struct uci_optmap {
        int detected_type;
        int (*parse)(void *section, struct uci_optmap *om, union ucimap_data *data, const char *string);
        int (*format)(void *section, struct uci_optmap *om, union ucimap_data *data, char **string);
+       void (*free)(void *section, struct uci_optmap *om, void *ptr);
        union {
                struct {
                        int base;
@@ -205,5 +211,6 @@ extern void ucimap_set_changed(struct ucimap_section_data *sd, void *field);
 extern int ucimap_store_section(struct uci_map *map, struct uci_package *p, struct ucimap_section_data *sd);
 extern void ucimap_parse(struct uci_map *map, struct uci_package *pkg);
 extern int ucimap_parse_section(struct uci_map *map, struct uci_sectionmap *sm, struct ucimap_section_data *sd, struct uci_section *s);
+extern void ucimap_free_section(struct uci_map *map, struct ucimap_section_data *sd);
 
 #endif