mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-05 09:14:03 +00:00
Move logic to destroy a struct catentry to its own function.
This will be used later for memory leak handling. Obtained from: OneFS Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
parent
0fd00e0caa
commit
b231dc0a9f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295176
@ -325,6 +325,21 @@ catgets(nl_catd catd, int set_id, int msg_id, const char *s)
|
||||
return ((char *)s);
|
||||
}
|
||||
|
||||
static void
|
||||
catfree(struct catentry *np)
|
||||
{
|
||||
|
||||
if (np->catd != NULL && np->catd != NLERR) {
|
||||
munmap(np->catd->__data, (size_t)np->catd->__size);
|
||||
free(np->catd);
|
||||
}
|
||||
SLIST_REMOVE(&cache, np, catentry, list);
|
||||
free(np->name);
|
||||
free(np->path);
|
||||
free(np->lang);
|
||||
free(np);
|
||||
}
|
||||
|
||||
int
|
||||
catclose(nl_catd catd)
|
||||
{
|
||||
@ -341,15 +356,8 @@ catclose(nl_catd catd)
|
||||
SLIST_FOREACH(np, &cache, list) {
|
||||
if (catd == np->catd) {
|
||||
np->refcount--;
|
||||
if (np->refcount == 0) {
|
||||
munmap(catd->__data, (size_t)catd->__size);
|
||||
free(catd);
|
||||
SLIST_REMOVE(&cache, np, catentry, list);
|
||||
free(np->name);
|
||||
free(np->path);
|
||||
free(np->lang);
|
||||
free(np);
|
||||
}
|
||||
if (np->refcount == 0)
|
||||
catfree(np);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user