projects
/
project
/
uci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
3fa4e98
)
ucimap: allow api users to take over allocation of section data structures
author
Felix Fietkau
<nbd@openwrt.org>
Sat, 29 Aug 2009 20:59:02 +0000
(22:59 +0200)
committer
Felix Fietkau
<nbd@openwrt.org>
Sat, 29 Aug 2009 20:59:02 +0000
(22:59 +0200)
ucimap.c
patch
|
blob
|
history
ucimap.h
patch
|
blob
|
history
diff --git
a/ucimap.c
b/ucimap.c
index
455cf36
..
d4dc05f
100644
(file)
--- a/
ucimap.c
+++ b/
ucimap.c
@@
-282,11
+282,17
@@
ucimap_parse_section(struct uci_map *map, struct uci_sectionmap *sm, struct uci_
int n_alloc = 2;
int err;
int n_alloc = 2;
int err;
- sd = malloc(sm->alloc_len);
+ if (sm->alloc) {
+ sd = sm->alloc(map, sm, s);
+ memset(sd, 0, sizeof(struct ucimap_section_data));
+ } else {
+ sd = malloc(sm->alloc_len);
+ memset(sd, 0, sm->alloc_len);
+ }
+
if (!sd)
return UCI_ERR_MEM;
if (!sd)
return UCI_ERR_MEM;
- memset(sd, 0, sm->alloc_len);
INIT_LIST_HEAD(&sd->list);
sd->map = map;
sd->sm = sm;
INIT_LIST_HEAD(&sd->list);
sd->map = map;
sd->sm = sm;
diff --git
a/ucimap.h
b/ucimap.h
index
4254b1e
..
921ab4e
100644
(file)
--- a/
ucimap.h
+++ b/
ucimap.h
@@
-109,6
+109,10
@@
struct uci_sectionmap {
/* sectionmap offset */
unsigned int smap_offset;
/* sectionmap offset */
unsigned int smap_offset;
+ /* allocate a new data structure and return a pointer to the section map data */
+ struct ucimap_section_data *(*alloc)(struct uci_map *map,
+ struct uci_sectionmap *sm, struct uci_section *s);
+
/* give the caller time to initialize the preallocated struct */
int (*init)(struct uci_map *map, void *section, struct uci_section *s);
/* give the caller time to initialize the preallocated struct */
int (*init)(struct uci_map *map, void *section, struct uci_section *s);