]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add new apr functions/macros needed by unimrcp update
authorMichael Jerris <mike@jerris.com>
Thu, 19 Nov 2009 14:24:59 +0000 (14:24 +0000)
committerMichael Jerris <mike@jerris.com>
Thu, 19 Nov 2009 14:24:59 +0000 (14:24 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15542 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/apr/.update
libs/apr/include/apr_hash.h
libs/apr/include/apr_tables.h
libs/apr/tables/apr_hash.c
libs/apr/tables/apr_tables.c

index 274a4b5e2efb0980d5970ad8d265d95186dd793b..097f707e64b8b188694a2e83dbd92d8f4370a091 100644 (file)
@@ -1 +1 @@
-Mon Jun  8 11:30:01 EDT 2009
+Thu Nov 19 09:24:37 EST 2009
index 454a4e9cee00865c2bdcc032e94425292fae404e..353709b145d300db4bf1393ab73afcb2a6a9f0fa 100644 (file)
@@ -174,6 +174,12 @@ APR_DECLARE(void) apr_hash_this(apr_hash_index_t *hi, const void **key,
  */
 APR_DECLARE(unsigned int) apr_hash_count(apr_hash_t *ht);
 
+/**
+ * Clear any key/value pairs in the hash table.
+ * @param ht The hash table
+ */
+APR_DECLARE(void) apr_hash_clear(apr_hash_t *ht);
+
 /**
  * Merge two hash tables into one new hash table. The values of the overlay
  * hash override the values of the base if both have the same key.  Both
index 6e9bb585d0481c384d311b15d8ba4227b50c9070..632f5b71b491a2455a981ef30dfebfc0befabd68 100644 (file)
@@ -120,6 +120,25 @@ APR_DECLARE(apr_array_header_t *) apr_array_make(apr_pool_t *p,
  */
 APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr);
 
+/** A helper macro for accessing a member of an APR array.
+ *
+ * @param ary the array
+ * @param i the index into the array to return
+ * @param type the type of the objects stored in the array
+ *
+ * @return the item at index i
+ */
+#define APR_ARRAY_IDX(ary,i,type) (((type *)(ary)->elts)[i])
+
+/** A helper macro for pushing elements into an APR array.
+ *
+ * @param ary the array
+ * @param type the type of the objects stored in the array
+ *
+ * @return the location where the new object should be placed
+ */
+#define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push(ary)))
+
 /**
  * Remove an element from an array (as a first-in, last-out stack)
  * @param arr The array to remove an element from.
@@ -128,6 +147,14 @@ APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr);
  */
 APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr);
 
+/**
+ * Remove all elements from an array.
+ * @param arr The array to remove all elements from.
+ * @remark As the underlying storage is allocated from a pool, no
+ * memory is freed by this operation, but is available for reuse.
+ */
+APR_DECLARE(void) apr_array_clear(apr_array_header_t *arr);
+
 /**
  * Concatenate two arrays together
  * @param dst The destination array, and the one to go first in the combined 
index 6f58d98bcee797f0d6dbab117dfe2c498b367b08..4e3723e19f111f3c25af8564b986b6e1e63ce248 100644 (file)
@@ -367,6 +367,13 @@ APR_DECLARE(unsigned int) apr_hash_count(apr_hash_t *ht)
     return ht->count;
 }
 
+APR_DECLARE(void) apr_hash_clear(apr_hash_t *ht)
+{
+    apr_hash_index_t *hi;
+    for (hi = apr_hash_first(NULL, ht); hi; hi = apr_hash_next(hi))
+        apr_hash_set(ht, hi->this->key, hi->this->klen, NULL);
+}
+
 APR_DECLARE(apr_hash_t*) apr_hash_overlay(apr_pool_t *p,
                                           const apr_hash_t *overlay,
                                           const apr_hash_t *base)
index 54b6eb069c9ccf8fc30334659e37c77eec321f13..5a1dfa26196baeb1594d463a1ec6c8dbdb30bff7 100644 (file)
@@ -90,6 +90,11 @@ APR_DECLARE(apr_array_header_t *) apr_array_make(apr_pool_t *p,
     return res;
 }
 
+APR_DECLARE(void) apr_array_clear(apr_array_header_t *arr)
+{
+    arr->nelts = 0;
+}
+
 APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr)
 {
     if (apr_is_empty_array(arr)) {