summaryrefslogtreecommitdiffstats
path: root/libcutils
diff options
context:
space:
mode:
authorGreg Hackmann <ghackmann@google.com>2013-02-12 14:41:59 -0800
committerColin Cross <ccross@android.com>2013-06-18 19:26:27 -0700
commit6967935eb30875ca9caf4717684141c92a0b6d4b (patch)
tree3a6a95647757271cad45cb332f4cb27bb6a06794 /libcutils
parentd92e35eb7b97f349054390cfee1d40154dba6d66 (diff)
downloadsystem_core-6967935eb30875ca9caf4717684141c92a0b6d4b.zip
system_core-6967935eb30875ca9caf4717684141c92a0b6d4b.tar.gz
system_core-6967935eb30875ca9caf4717684141c92a0b6d4b.tar.bz2
libcutils: reimplement property_list() using __system_property_foreach()
Signed-off-by: Greg Hackmann <ghackmann@google.com> (cherry picked from commit e7bb159d16f9e60850a3c79cc388587959015a65) Change-Id: I0f66144eb8a4a48e04e4fcd125ad37f19ad94b8e
Diffstat (limited to 'libcutils')
-rw-r--r--libcutils/properties.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/libcutils/properties.c b/libcutils/properties.c
index f732ec0..28d8b2f 100644
--- a/libcutils/properties.c
+++ b/libcutils/properties.c
@@ -52,19 +52,28 @@ int property_get(const char *key, char *value, const char *default_value)
return len;
}
-int property_list(void (*propfn)(const char *key, const char *value, void *cookie),
- void *cookie)
+struct property_list_callback_data
+{
+ void (*propfn)(const char *key, const char *value, void *cookie);
+ void *cookie;
+};
+
+static void property_list_callback(const prop_info *pi, void *cookie)
{
char name[PROP_NAME_MAX];
char value[PROP_VALUE_MAX];
- const prop_info *pi;
- unsigned n;
-
- for(n = 0; (pi = __system_property_find_nth(n)); n++) {
- __system_property_read(pi, name, value);
- propfn(name, value, cookie);
- }
- return 0;
+ struct property_list_callback_data *data = cookie;
+
+ __system_property_read(pi, name, value);
+ data->propfn(name, value, data->cookie);
+}
+
+int property_list(
+ void (*propfn)(const char *key, const char *value, void *cookie),
+ void *cookie)
+{
+ struct property_list_callback_data data = { propfn, cookie };
+ return __system_property_foreach(property_list_callback, &data);
}
#elif defined(HAVE_SYSTEM_PROPERTY_SERVER)