#include <stdio.h>
#include <stdlib.h>
#include <time.h>
-#include "cryptlib.h"
+#include "internal/cryptlib.h"
#include <openssl/crypto.h>
#include <openssl/buffer.h>
#include <openssl/bio.h>
static void app_info_free(APP_INFO *inf)
{
+ if (!inf)
+ return;
if (--(inf->references) <= 0) {
- if (inf->next != NULL) {
- app_info_free(inf->next);
- }
+ app_info_free(inf->next);
OPENSSL_free(inf);
}
}
static unsigned long mem_hash(const MEM *a)
{
- unsigned long ret;
+ size_t ret;
- ret = (unsigned long)a->addr;
+ ret = (size_t)a->addr;
ret = ret * 17851 + (ret >> 14) * 7 + (ret >> 4) * 251;
return (ret);
if (is_MemCheck_on()) {
MemCheck_off(); /* obtain MALLOC2 lock */
- if ((ami = OPENSSL_malloc(sizeof(APP_INFO))) == NULL) {
+ if ((ami = OPENSSL_malloc(sizeof(*ami))) == NULL) {
ret = 0;
goto err;
}
if (is_MemCheck_on()) {
MemCheck_off(); /* make sure we hold MALLOC2 lock */
- if ((m = OPENSSL_malloc(sizeof(MEM))) == NULL) {
+ if ((m = OPENSSL_malloc(sizeof(*m))) == NULL) {
OPENSSL_free(addr);
MemCheck_on(); /* release MALLOC2 lock if num_disabled drops
* to 0 */
fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] - 0x%p (%d)\n",
mp->order, mp->addr, mp->num);
#endif
- if (mp->app_info != NULL)
- app_info_free(mp->app_info);
+ app_info_free(mp->app_info);
OPENSSL_free(mp);
}
bufp += strlen(bufp);
}
- BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\n",
- m->num, (unsigned long)m->addr);
+ BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%p\n",
+ m->num, m->addr);
bufp += strlen(bufp);
BIO_puts(l->bio, buf);
old_mh_mode = mh_mode;
mh_mode = CRYPTO_MEM_CHECK_OFF;
- if (mh != NULL) {
- lh_MEM_free(mh);
- mh = NULL;
- }
+ lh_MEM_free(mh);
+ mh = NULL;
if (amih != NULL) {
if (lh_APP_INFO_num_items(amih) == 0) {
lh_APP_INFO_free(amih);