subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1663896 - in /subversion/trunk/subversion: include/svn_hash.h libsvn_subr/hash.c
Date Wed, 04 Mar 2015 09:03:14 GMT
Author: julianfoad
Date: Wed Mar  4 09:03:13 2015
New Revision: 1663896

URL: http://svn.apache.org/r1663896
Log:
Redefine the svn_hash_sets macro to match the way svn_hash_gets is defined,
thus avoiding a backward compatibility problem. A follow-up to r1663760 and
r1663780.

Found by: danielsh

* subversion/include/svn_hash.h
  (svn_hash__sets): New function.
  (svn_hash_sets): In debug mode, call svn_hash__sets; in release mode, call
    apr_hash_set directly.

* subversion/libsvn_subr/hash.c
  (svn_hash__sets): New function.

Modified:
    subversion/trunk/subversion/include/svn_hash.h
    subversion/trunk/subversion/libsvn_subr/hash.c

Modified: subversion/trunk/subversion/include/svn_hash.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_hash.h?rev=1663896&r1=1663895&r2=1663896&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_hash.h (original)
+++ subversion/trunk/subversion/include/svn_hash.h Wed Mar  4 09:03:13 2015
@@ -239,13 +239,14 @@ svn_hash_from_cstring_keys(apr_hash_t **
                            const apr_array_header_t *keys,
                            apr_pool_t *pool);
 
-/* In debug builds, the svn_hash_gets macro forwards the parameters
- * through this function in order to have parameter type checking,
- * particularly for the key. The svn_hash_sets macro gets parameter
- * type checking in a different way, by using an in-line assignment.
+/* In debug builds, the svn_hash_gets and svn_hash_sets macros forward their
+ * parameters through these functions in order to gain type checking for the
+ * 'key' parameter which the basic apr_hash_* APIs declare only as 'void *'.
  */
 void *
 svn_hash__gets(apr_hash_t *ht, const char *key);
+void
+svn_hash__sets(apr_hash_t *ht, const char *key, const void *value);
 
 /** Shortcut for apr_hash_get() with a const char * key.
  *
@@ -263,11 +264,13 @@ svn_hash__gets(apr_hash_t *ht, const cha
  *
  * @since New in 1.8.
  */
-#define svn_hash_sets(ht, key, val)                                         \
-  do {                                                                      \
-    const char *svn_hash__key = (key);                                      \
-    apr_hash_set(ht, svn_hash__key, APR_HASH_KEY_STRING, val);              \
-  } while (0)
+#ifdef SVN_DEBUG
+#define svn_hash_sets(ht, key, val) \
+            svn_hash__sets(ht, key, val)
+#else
+#define svn_hash_gets(ht, key) \
+            apr_hash_set(ht, svn_hash__key, APR_HASH_KEY_STRING, val)
+#endif
 
 /** @} */
 

Modified: subversion/trunk/subversion/libsvn_subr/hash.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/hash.c?rev=1663896&r1=1663895&r2=1663896&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/hash.c (original)
+++ subversion/trunk/subversion/libsvn_subr/hash.c Wed Mar  4 09:03:13 2015
@@ -567,6 +567,13 @@ svn_hash__gets(apr_hash_t *ht, const cha
 }
 
 
+void
+svn_hash__sets(apr_hash_t *ht, const char *key, const void *val)
+{
+  return apr_hash_set(ht, key, APR_HASH_KEY_STRING, val);
+}
+
+
 
 /*** Specialized getter APIs ***/
 



Mime
View raw message