diff options
author | markus <> | 2003-05-11 21:36:58 +0000 |
---|---|---|
committer | markus <> | 2003-05-11 21:36:58 +0000 |
commit | 1c98a87f0daac81245653c227eb2f2508a22a965 (patch) | |
tree | 3de6d603296ec563b936da4e6a8a1e33d48f8884 /src/lib/libcrypto/mem_dbg.c | |
parent | 31392c89d1135cf2a416f97295f6d21681b3fbc4 (diff) | |
download | openbsd-1c98a87f0daac81245653c227eb2f2508a22a965.tar.gz openbsd-1c98a87f0daac81245653c227eb2f2508a22a965.tar.bz2 openbsd-1c98a87f0daac81245653c227eb2f2508a22a965.zip |
import 0.9.7b (without idea and rc5)
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 1c4e04f51f..57bd08f65d 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 | ||
@@ -666,7 +678,6 @@ static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM *, MEM_LEAK *) | |||
666 | void CRYPTO_mem_leaks(BIO *b) | 678 | void CRYPTO_mem_leaks(BIO *b) |
667 | { | 679 | { |
668 | MEM_LEAK ml; | 680 | MEM_LEAK ml; |
669 | char buf[80]; | ||
670 | 681 | ||
671 | if (mh == NULL && amih == NULL) | 682 | if (mh == NULL && amih == NULL) |
672 | return; | 683 | return; |
@@ -681,9 +692,8 @@ void CRYPTO_mem_leaks(BIO *b) | |||
681 | (char *)&ml); | 692 | (char *)&ml); |
682 | if (ml.chunks != 0) | 693 | if (ml.chunks != 0) |
683 | { | 694 | { |
684 | sprintf(buf,"%ld bytes leaked in %d chunks\n", | 695 | BIO_printf(b,"%ld bytes leaked in %d chunks\n", |
685 | ml.bytes,ml.chunks); | 696 | ml.bytes,ml.chunks); |
686 | BIO_puts(b,buf); | ||
687 | } | 697 | } |
688 | else | 698 | else |
689 | { | 699 | { |