[or-cvs] even better function start checks; give dmalloc a chance of...

Nick Mathewson nickm at seul.org
Fri Sep 30 01:39:26 UTC 2005


Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv13047/src/common

Modified Files:
	container.c crypto.c util.c util.h 
Log Message:
even better function start checks; give dmalloc a chance of working.

Index: container.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/container.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- container.c	30 Sep 2005 01:09:52 -0000	1.41
+++ container.c	30 Sep 2005 01:39:24 -0000	1.42
@@ -550,7 +550,8 @@
 /** Return the current value associated with <b>key</b>, or NULL if no
  * value is set.
  */
-void *strmap_get(strmap_t *map, const char *key)
+void *
+strmap_get(strmap_t *map, const char *key)
 {
   strmap_entry_t *resolve;
   strmap_entry_t search;

Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/crypto.c,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -d -r1.158 -r1.159
--- crypto.c	30 Sep 2005 01:09:52 -0000	1.158
+++ crypto.c	30 Sep 2005 01:39:24 -0000	1.159
@@ -242,7 +242,8 @@
 }
 
 /** used by tortls.c: wrap an RSA* in a crypto_pk_env_t. */
-crypto_pk_env_t *_crypto_new_pk_env_rsa(RSA *rsa)
+crypto_pk_env_t *
+_crypto_new_pk_env_rsa(RSA *rsa)
 {
   crypto_pk_env_t *env;
   tor_assert(rsa);
@@ -253,14 +254,16 @@
 }
 
 /** used by tortls.c: return the RSA* from a crypto_pk_env_t. */
-RSA *_crypto_pk_env_get_rsa(crypto_pk_env_t *env)
+RSA *
+_crypto_pk_env_get_rsa(crypto_pk_env_t *env)
 {
   return env->key;
 }
 
 /** used by tortls.c: get an equivalent EVP_PKEY* for a crypto_pk_env_t.  Iff
  * private is set, include the private-key portion of the key. */
-EVP_PKEY *_crypto_pk_env_get_evp_pkey(crypto_pk_env_t *env, int private)
+EVP_PKEY *
+_crypto_pk_env_get_evp_pkey(crypto_pk_env_t *env, int private)
 {
   RSA *key = NULL;
   EVP_PKEY *pkey = NULL;
@@ -287,7 +290,8 @@
 
 /** Used by tortls.c: Get the DH* from a crypto_dh_env_t.
  */
-DH *_crypto_dh_env_get_dh(crypto_dh_env_t *dh)
+DH *
+_crypto_dh_env_get_dh(crypto_dh_env_t *dh)
 {
   return dh->dh;
 }
@@ -295,7 +299,8 @@
 /** Allocate and return storage for a public key.  The key itself will not yet
  * be set.
  */
-crypto_pk_env_t *crypto_new_pk_env(void)
+crypto_pk_env_t *
+crypto_new_pk_env(void)
 {
   RSA *rsa;
 
@@ -358,7 +363,8 @@
 
 /** Allocate and return a new symmetric cipher.
  */
-crypto_cipher_env_t *crypto_new_cipher_env(void)
+crypto_cipher_env_t *
+crypto_new_cipher_env(void)
 {
   crypto_cipher_env_t *env;
 

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.225
retrieving revision 1.226
diff -u -d -r1.225 -r1.226
--- util.c	30 Sep 2005 01:09:52 -0000	1.225
+++ util.c	30 Sep 2005 01:39:24 -0000	1.226
@@ -115,7 +115,8 @@
  * <b>file</b> and <b>line</b> are used if dmalloc is enabled, and
  * ignored otherwise.
  */
-void *_tor_malloc(DMALLOC_PARAMS size_t size)
+void *
+_tor_malloc(DMALLOC_PARAMS size_t size)
 {
   void *result;
 

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.h,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- util.h	29 Sep 2005 22:59:17 -0000	1.140
+++ util.h	30 Sep 2005 01:39:24 -0000	1.141
@@ -66,7 +66,18 @@
 void *_tor_realloc(DMALLOC_PARAMS void *ptr, size_t size);
 char *_tor_strdup(DMALLOC_PARAMS const char *s);
 char *_tor_strndup(DMALLOC_PARAMS const char *s, size_t n);
+#ifdef USE_DMALLOC
+extern int dmalloc_free(const char *file, const int line, void *pnt,
+                        const int func_id);
+#define tor_free(p) do { \
+    if (p) {                                        \
+      dmalloc_free(_SHORT_FILE_, __LINE__, (p), 0); \
+      (p)=NULL;                                     \
+    }                                               \
+  } while (0)
+#else
 #define tor_free(p) do { if (p) {free(p); (p)=NULL;} } while (0)
+#endif
 
 #define tor_malloc(size)       _tor_malloc(DMALLOC_ARGS size)
 #define tor_malloc_zero(size)  _tor_malloc_zero(DMALLOC_ARGS size)



More information about the tor-commits mailing list