[augeas-devel] [PATCH 5/8] * src/augeas.c (tree_find): helper for getting a tree node
David Lutterkort
lutter at redhat.com
Wed Feb 25 21:58:35 UTC 2009
---
src/augeas.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/augeas.c b/src/augeas.c
index 529cbf7..1ac3df9 100644
--- a/src/augeas.c
+++ b/src/augeas.c
@@ -663,21 +663,29 @@ static int update_save_flags(struct augeas *aug) {
return 0;
}
+static struct tree *tree_find(struct tree *origin, const char *path) {
+ struct pathx *px = NULL;
+ struct tree *result = NULL;
+
+ if (pathx_parse(origin, path, &px) != 0)
+ return NULL;
+
+ pathx_find_one(px, &result);
+ free_pathx(px);
+
+ return result;
+}
+
int aug_save(struct augeas *aug) {
int ret = 0;
struct tree *files;
- struct pathx *p = NULL;
if (update_save_flags(aug) < 0)
return -1;
- if (pathx_parse(aug->origin, AUGEAS_FILES_TREE, &p) != 0)
- return -1;
- if (pathx_find_one(p, &files) != 1) {
- free_pathx(p);
+ files = tree_find(aug->origin, AUGEAS_FILES_TREE);
+ if (files == NULL)
return -1;
- }
- free_pathx(p);
aug_rm(aug, AUGEAS_EVENTS_SAVED);
--
1.6.0.6
More information about the augeas-devel
mailing list