summaryrefslogtreecommitdiffstats
path: root/crypto/mem.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>1999-11-12 21:51:24 +0000
committerRichard Levitte <levitte@openssl.org>1999-11-12 21:51:24 +0000
commit6828f02c9aa644e77d2e440260de1a080b68f6ee (patch)
treeb84073ca2d249e0ec2e9857fe8a4759605e65102 /crypto/mem.c
parent47d216940c454b8c6d229565051116c1108ddd2d (diff)
The info removal code was overcomplicated, and error-prone (references being wrongly decreased). Fixed.
Diffstat (limited to 'crypto/mem.c')
-rw-r--r--crypto/mem.c35
1 files changed, 11 insertions, 24 deletions
diff --git a/crypto/mem.c b/crypto/mem.c
index 1498672800..e2688994ae 100644
--- a/crypto/mem.c
+++ b/crypto/mem.c
@@ -223,27 +223,6 @@ static unsigned long app_info_hash(APP_INFO *a)
return(ret);
}
-static APP_INFO *free_info(APP_INFO *app_info)
- {
- 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;
@@ -255,6 +234,12 @@ static APP_INFO *remove_info()
if ((ret=(APP_INFO *)lh_delete(amih,(char *)&tmp)) != NULL)
{
APP_INFO *next=ret->next;
+
+ if (next != NULL)
+ {
+ next->references++;
+ lh_insert(amih,(char *)next);
+ }
#ifdef LEVITTE_DEBUG
if (ret->thread != tmp.thread)
{
@@ -263,11 +248,13 @@ static APP_INFO *remove_info()
abort();
}
#endif
- if (next != NULL)
+ if (--(ret->references) <= 0)
{
- lh_insert(amih,(char *)next);
+ ret->next = NULL;
+ if (next != NULL)
+ next->references--;
+ Free(ret);
}
- free_info(ret);
}
}
return(ret);