Submit #1398 ยป hdestroy-3-Don-t-call-free-3-for-each-hash-key.patch
| lib/libc/stdlib/hcreate.3 | ||
|---|---|---|
|
.\" $FreeBSD: src/lib/libc/stdlib/hcreate.3,v 1.7 2008/07/06 17:03:37 danger Exp $
|
||
|
.\" $DragonFly: src/lib/libc/stdlib/hcreate.3,v 1.5 2006/05/26 19:39:37 swildner Exp $
|
||
|
.\"
|
||
|
.Dd July 6, 2008
|
||
|
.Dd June 10, 2009
|
||
|
.Os
|
||
|
.Dt HCREATE 3
|
||
|
.Sh NAME
|
||
| ... | ... | |
|
After the call to
|
||
|
.Fn hdestroy ,
|
||
|
the data can no longer be considered accessible.
|
||
|
The
|
||
|
.Fn hdestroy
|
||
|
function calls
|
||
|
.Xr free 3
|
||
|
for each comparison key in the search table
|
||
|
but not the data item associated with the key.
|
||
|
.Pp
|
||
|
The
|
||
|
.Fn hsearch
|
||
| ... | ... | |
|
indicated by the return of a
|
||
|
.Dv NULL
|
||
|
pointer.
|
||
|
.Pp
|
||
|
The comparison key (passed to
|
||
|
.Fn hsearch
|
||
|
as
|
||
|
.Fa item.key )
|
||
|
must be allocated using
|
||
|
.Xr malloc 3
|
||
|
if
|
||
|
.Fa action
|
||
|
is
|
||
|
.Dv ENTER
|
||
|
and
|
||
|
.Fn hdestroy
|
||
|
is called.
|
||
|
.Sh RETURN VALUES
|
||
|
The
|
||
|
.Fn hcreate
|
||
| lib/libc/stdlib/hcreate.c | ||
|---|---|---|
|
while (!SLIST_EMPTY(&htable[idx])) {
|
||
|
ie = SLIST_FIRST(&htable[idx]);
|
||
|
SLIST_REMOVE_HEAD(&htable[idx], link);
|
||
|
free(ie->ent.key);
|
||
|
free(ie);
|
||
|
}
|
||
|
}
|
||