diff options
author | markus <> | 2003-05-12 02:18:40 +0000 |
---|---|---|
committer | markus <> | 2003-05-12 02:18:40 +0000 |
commit | d4fcd82bb7f6d603bd61e19a81ba97337b89dfca (patch) | |
tree | d52e3a0f1f08f65ad283027e560e17ed0d720462 /src/lib/libcrypto/mem_dbg.c | |
parent | 582bbd139cd2afd58d10dc051c5b0b989b441074 (diff) | |
download | openbsd-d4fcd82bb7f6d603bd61e19a81ba97337b89dfca.tar.gz openbsd-d4fcd82bb7f6d603bd61e19a81ba97337b89dfca.tar.bz2 openbsd-d4fcd82bb7f6d603bd61e19a81ba97337b89dfca.zip |
merge 0.9.7b with local changes; crank majors for libssl/libcrypto
Diffstat (limited to 'src/lib/libcrypto/mem_dbg.c')
-rw-r--r-- | src/lib/libcrypto/mem_dbg.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/lib/libcrypto/mem_dbg.c b/src/lib/libcrypto/mem_dbg.c index ea94eee6f4..9221df00bd 100644 --- a/src/lib/libcrypto/mem_dbg.c +++ b/src/lib/libcrypto/mem_dbg.c | |||
@@ -102,6 +102,8 @@ typedef struct app_mem_info_st | |||
102 | int references; | 102 | int references; |
103 | } APP_INFO; | 103 | } APP_INFO; |
104 | 104 | ||
105 | static void app_info_free(APP_INFO *); | ||
106 | |||
105 | static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's | 107 | static LHASH *amih=NULL; /* hash-table with those app_mem_info_st's |
106 | * that are at the top of their thread's stack | 108 | * that are at the top of their thread's stack |
107 | * (with `thread' as key); | 109 | * (with `thread' as key); |
@@ -140,6 +142,18 @@ static unsigned long disabling_thread = 0; /* Valid iff num_disable > 0. | |||
140 | * thread named in disabling_thread). | 142 | * thread named in disabling_thread). |
141 | */ | 143 | */ |
142 | 144 | ||
145 | static void app_info_free(APP_INFO *inf) | ||
146 | { | ||
147 | if (--(inf->references) <= 0) | ||
148 | { | ||
149 | if (inf->next != NULL) | ||
150 | { | ||
151 | app_info_free(inf->next); | ||
152 | } | ||
153 | OPENSSL_free(inf); | ||
154 | } | ||
155 | } | ||
156 | |||
143 | int CRYPTO_mem_ctrl(int mode) | 157 | int CRYPTO_mem_ctrl(int mode) |
144 | { | 158 | { |
145 | int ret=mh_mode; | 159 | int ret=mh_mode; |
@@ -502,9 +516,7 @@ void CRYPTO_dbg_free(void *addr, int before_p) | |||
502 | mp->order, mp->addr, mp->num); | 516 | mp->order, mp->addr, mp->num); |
503 | #endif | 517 | #endif |
504 | if (mp->app_info != NULL) | 518 | if (mp->app_info != NULL) |
505 | { | 519 | app_info_free(mp->app_info); |
506 | mp->app_info->references--; | ||
507 | } | ||
508 | OPENSSL_free(mp); | 520 | OPENSSL_free(mp); |
509 | } | 521 | } |
510 | 522 | ||
@@ -669,7 +681,6 @@ static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM *, MEM_LEAK *) | |||
669 | void CRYPTO_mem_leaks(BIO *b) | 681 | void CRYPTO_mem_leaks(BIO *b) |
670 | { | 682 | { |
671 | MEM_LEAK ml; | 683 | MEM_LEAK ml; |
672 | char buf[80]; | ||
673 | 684 | ||
674 | if (mh == NULL && amih == NULL) | 685 | if (mh == NULL && amih == NULL) |
675 | return; | 686 | return; |
@@ -684,9 +695,8 @@ void CRYPTO_mem_leaks(BIO *b) | |||
684 | (char *)&ml); | 695 | (char *)&ml); |
685 | if (ml.chunks != 0) | 696 | if (ml.chunks != 0) |
686 | { | 697 | { |
687 | snprintf(buf,sizeof buf,"%ld bytes leaked in %d chunks\n", | 698 | BIO_printf(b,"%ld bytes leaked in %d chunks\n", |
688 | ml.bytes,ml.chunks); | 699 | ml.bytes,ml.chunks); |
689 | BIO_puts(b,buf); | ||
690 | } | 700 | } |
691 | else | 701 | else |
692 | { | 702 | { |