[augeas-devel] augeas: master - * src/augeas.c (tree_find): helper for getting a tree node
David Lutterkort
lutter at fedoraproject.org
Thu Feb 26 23:43:34 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=0bf455038f27257ff3abd77bfaf7a35e8f2778ed
Commit: 0bf455038f27257ff3abd77bfaf7a35e8f2778ed
Parent: 856a6c16a7279187f0c1b7ef6965461328f4bba0
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Wed Feb 25 11:15:09 2009 -0800
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Wed Feb 25 11:15:09 2009 -0800
* src/augeas.c (tree_find): helper for getting a tree node
---
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);
More information about the augeas-devel
mailing list