- APP_INFO *next;
-
- if (app_info == NULL)
- return NULL;
-
- if (--(app_info->references) > 0)
- return app_info;
-
- app_info->references = 0;
-
- next = app_info->next;
- app_info->next = NULL; /* Just to make sure */
-
- Free(app_info);
- if (next != app_info)
- return free_info(next);
- return NULL;
- }
-
-static APP_INFO *remove_info()
- {
- APP_INFO tmp;
- APP_INFO *ret = NULL;
-
- if (amih != NULL)
- {
- tmp.thread=CRYPTO_thread_id();
- if ((ret=(APP_INFO *)lh_delete(amih,(char *)&tmp)) != NULL)
- {
- APP_INFO *next=ret->next;
-#ifdef LEVITTE_DEBUG
- if (ret->thread != tmp.thread)
- {
- fprintf(stderr, "remove_info(): deleted info has other thread ID (%d) than the current thread (%d)!!!!\n",
- ret->thread, tmp.thread);
- abort();
- }
-#endif
- if (next != NULL)
- {
- lh_insert(amih,(char *)next);
- }
- free_info(ret);
- }
- }
- return(ret);
- }
-
-int CRYPTO_add_info(const char *file, int line, const char *info)
- {
- APP_INFO *ami, *amim;
- int ret=0;
-
- if (is_MemCheck_On())
- {
- MemCheck_off();
-
- if ((ami = (APP_INFO *)Malloc(sizeof(APP_INFO))) == NULL)
- {
- ret=0;
- goto err;
- }
- if (amih == NULL)
- {
- if ((amih=lh_new(app_info_hash,app_info_cmp)) == NULL)
- {
- Free(ami);
- ret=0;
- goto err;
- }
- }
-
- ami->thread=CRYPTO_thread_id();
- ami->file=file;
- ami->line=line;
- ami->info=info;
- ami->references=1;
- ami->next=NULL;
-
- if ((amim=(APP_INFO *)lh_insert(amih,(char *)ami)) != NULL)
- {
-#ifdef LEVITTE_DEBUG
- if (ami->thread != amim->thread)
- {
- fprintf(stderr, "CRYPTO_add_info(): previous info has other thread ID (%d) than the current thread (%d)!!!!\n",
- amim->thread, ami->thread);
- abort();
- }
-#endif
- ami->next=amim;
- }
- err:
- MemCheck_on();
- }
-
- return(ret);
- }
-
-int CRYPTO_remove_info()
- {
- int ret=0;
-
- if (is_MemCheck_On())
- {
- MemCheck_off();
-
- ret=(remove_info() != NULL);
-
- MemCheck_on();
- }
- return(ret);
- }
-
-static char *(*malloc_locked_func)()=(char *(*)())malloc;
-static void (*free_locked_func)()=(void (*)())free;
-static char *(*malloc_func)()= (char *(*)())malloc;
-static char *(*realloc_func)()= (char *(*)())realloc;
-static void (*free_func)()= (void (*)())free;
-
-void CRYPTO_set_mem_functions(char *(*m)(), char *(*r)(), void (*f)())
- {
- if ((m == NULL) || (r == NULL) || (f == NULL)) return;