aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-09-30 01:39:24 +0000
committerNick Mathewson <nickm@torproject.org>2005-09-30 01:39:24 +0000
commit26e7a05725bcb2cea59401803371ee3fa688a8f6 (patch)
treeb81d9d8ee4672297b78012cecd17142616b2944e /src/common
parentedd15cb781934d91ae92adbe3311bf339ddbf2e8 (diff)
downloadtor-26e7a05725bcb2cea59401803371ee3fa688a8f6.tar
tor-26e7a05725bcb2cea59401803371ee3fa688a8f6.tar.gz
even better function start checks; give dmalloc a chance of working.
svn:r5162
Diffstat (limited to 'src/common')
-rw-r--r--src/common/container.c3
-rw-r--r--src/common/crypto.c18
-rw-r--r--src/common/util.c3
-rw-r--r--src/common/util.h11
4 files changed, 27 insertions, 8 deletions
diff --git a/src/common/container.c b/src/common/container.c
index 436c4bc01..39cabe9c5 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -550,7 +550,8 @@ strmap_set(strmap_t *map, const char *key, void *val)
/** 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;
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 7967e1f16..38e9931f8 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -242,7 +242,8 @@ crypto_global_cleanup(void)
}
/** 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 @@ crypto_pk_env_t *_crypto_new_pk_env_rsa(RSA *rsa)
}
/** 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 @@ EVP_PKEY *_crypto_pk_env_get_evp_pkey(crypto_pk_env_t *env, int private)
/** 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 @@ DH *_crypto_dh_env_get_dh(crypto_dh_env_t *dh)
/** 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 @@ crypto_create_init_cipher(const char *key, int encrypt_mode)
/** 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;
diff --git a/src/common/util.c b/src/common/util.c
index f8da6768a..07e26d85f 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -115,7 +115,8 @@ const char util_c_id[] = "$Id$";
* <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;
diff --git a/src/common/util.h b/src/common/util.h
index c4227b6d1..e644940b8 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -66,7 +66,18 @@ void *_tor_malloc_zero(DMALLOC_PARAMS size_t size);
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)