bionic: add __system_property_foreach

find_nth() will be inefficient on a trie.  Since find_nth() is only used
internally and only for enumerating properties, we can add a foreach()
function to do this directly.

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 577418403d)

Change-Id: Iaca97d1182ce2c28863ba85241cbb5cf6185eb2f
This commit is contained in:
Greg Hackmann
2013-02-12 16:39:31 -08:00
committed by Colin Cross
parent c656d732c7
commit c6ff844d75
3 changed files with 51 additions and 3 deletions

View File

@@ -76,13 +76,26 @@ int __system_property_read(const prop_info *pi, char *name, char *value);
** there is no nth property. Use __system_property_read() to
** read the value of this property.
**
** This method is for inspecting and debugging the property
** Please do not call this method. It only exists to provide
** backwards compatibility to NDK apps. Its implementation
** is inefficient and order of results may change from call
** to call.
*/
const prop_info *__system_property_find_nth(unsigned n);
/* Pass a prop_info for each system property to the provided
** callback. Use __system_property_read() to read the value
** of this property.
**
** This method is for inspecting and debugging the property
** system. Please use __system_property_find() instead.
**
** Order of results may change from call to call. This is
** not a bug.
*/
const prop_info *__system_property_find_nth(unsigned n);
*/
int __system_property_foreach(
void (*propfn)(const prop_info *pi, void *cookie),
void *cookie);
__END_DECLS