<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/lib/libc/stdlib/hcreate.3, branch main</title>
<subtitle>FreeBSD source tree</subtitle>
<id>http://cgit.freebsd.org/src/atom?h=main</id>
<link rel='self' href='http://cgit.freebsd.org/src/atom?h=main'/>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<updated>2026-06-10T12:35:05Z</updated>
<entry>
<title>hcreate(3): fix incorrect claim that hdestroy frees keys</title>
<updated>2026-06-10T12:35:05Z</updated>
<author>
<name>Kit Dallege</name>
<email>xaum.io@gmail.com</email>
</author>
<published>2026-03-27T01:57:10Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=ab8ceaaa86baa077fcdc020a0c05ccf88fcd54d1'/>
<id>urn:sha1:ab8ceaaa86baa077fcdc020a0c05ccf88fcd54d1</id>
<content type='text'>
The man page incorrectly stated that hdestroy() calls free(3) for
each comparison key. The implementation (hdestroy_r.c) only frees
the internal table structure, not the user-provided keys or data.
This matches POSIX, which says hdestroy "shall dispose of the
search table" without mentioning key deallocation.

Update the description to clarify that the caller is responsible
for freeing any memory associated with table entries.

PR: 291240
Signed-off-by: Kit Dallege &lt;xaum.io@gmail.com&gt;
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2095
</content>
</entry>
<entry>
<title>Remove $FreeBSD$: two-line nroff pattern</title>
<updated>2023-08-16T17:55:10Z</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-08-16T17:55:10Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=fa9896e082a1046ff4fbc75fcba4d18d1f2efc19'/>
<id>urn:sha1:fa9896e082a1046ff4fbc75fcba4d18d1f2efc19</id>
<content type='text'>
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
</content>
</entry>
<entry>
<title>hcreate(3): fix the ERRORS section and bump .Dd</title>
<updated>2017-02-07T02:32:49Z</updated>
<author>
<name>Enji Cooper</name>
<email>ngie@FreeBSD.org</email>
</author>
<published>2017-02-07T02:32:49Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=d5f154d3cfe6e4bb04cc3f0e61edced19b814553'/>
<id>urn:sha1:d5f154d3cfe6e4bb04cc3f0e61edced19b814553</id>
<content type='text'>
- Add missing comma between functions that trigger ENOMEM error.
- Fix the description for ESRCH. The action that triggers this error is
  FIND, not SEARCH (SEARCH does not exist).

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
</content>
</entry>
<entry>
<title>Replace implementation of hsearch() by one that scales.</title>
<updated>2015-12-27T07:50:11Z</updated>
<author>
<name>Ed Schouten</name>
<email>ed@FreeBSD.org</email>
</author>
<published>2015-12-27T07:50:11Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=2747eff1280f5cd8d5c375852f5db172ec87dd86'/>
<id>urn:sha1:2747eff1280f5cd8d5c375852f5db172ec87dd86</id>
<content type='text'>
Traditionally the hcreate() function creates a hash table that uses
chaining, using a fixed user-provided size. The problem with this
approach is that this often either wastes memory (table too big) or
yields bad performance (table too small). For applications it may not
always be easy to estimate the right hash table size. A fixed number
only increases performance compared to a linked list by a constant
factor.

This problem can be solved easily by dynamically resizing the hash
table. If the size of the hash table is at least doubled, this has no
negative on the running time complexity. If a dynamically sized hash
table is used, we can also switch to using open addressing instead of
chaining, which has the advantage of just using a single allocation for
the entire table, instead of allocating many small objects.

Finally, a problem with the existing implementation is that its
deterministic algorithm for hashing makes it possible to come up with
fixed patterns to trigger an excessive number of collisions. We can
easily solve this by using FNV-1a as a hashing algorithm in combination
with a randomly generated offset basis.

Measurements have shown that this implementation is about 20-25% faster
than the existing implementation (even if the existing implementation is
given an excessive number of buckets). Though it allocates more memory
through malloc() than the old implementation (between 4-8 pointers per
used entry instead of 3), process memory use is similar to the old
implementation as if the estimated size was underestimated by a factor
10. This is due to the fact that malloc() needs to perform less
bookkeeping.

Reviewed by:	jilles, pfg
Obtained from:	https://github.com/NuxiNL/cloudlibc
Differential Revision:	https://reviews.freebsd.org/D4644
</content>
</entry>
<entry>
<title>Add re-entrant versions of the hash functions based on the GNU api.</title>
<updated>2014-07-21T15:22:48Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2014-07-21T15:22:48Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=9823a90c79bac3a172a02f7e76947fcbb57e0955'/>
<id>urn:sha1:9823a90c79bac3a172a02f7e76947fcbb57e0955</id>
<content type='text'>
While testing this I found a conformance issue in hdestroy()
that will be fixed in a subsequent commit.

Obtained from:	NetBSD (hcreate.c, CVS Rev. 1.7)
</content>
</entry>
<entry>
<title>mdoc: order prologue macros consistently by Dd/Dt/Os</title>
<updated>2010-04-14T19:08:06Z</updated>
<author>
<name>Ulrich Spörlein</name>
<email>uqs@FreeBSD.org</email>
</author>
<published>2010-04-14T19:08:06Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=aa12cea2ccc6e686d6d31cf67d6bc69cbc1ba744'/>
<id>urn:sha1:aa12cea2ccc6e686d6d31cf67d6bc69cbc1ba744</id>
<content type='text'>
Although groff_mdoc(7) gives another impression, this is the ordering
most widely used and also required by mdocml/mandoc.

Reviewed by:	ru
Approved by:	philip, ed (mentors)
</content>
</entry>
<entry>
<title>- This code was intially obtained from NetBSD, but it's missing licence</title>
<updated>2008-07-06T17:03:37Z</updated>
<author>
<name>Daniel Gerzo</name>
<email>danger@FreeBSD.org</email>
</author>
<published>2008-07-06T17:03:37Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=5fd5badfa9a116a6274479968d6f5d82d0da3fee'/>
<id>urn:sha1:5fd5badfa9a116a6274479968d6f5d82d0da3fee</id>
<content type='text'>
  statement. Add the one from the current NetBSD version.
- Also bump a date to reflect my content changes I have done in previous
  revision

Approved by:	imp
MFC after:	3 days
</content>
</entry>
<entry>
<title>- Add description about a missing return value</title>
<updated>2008-07-06T12:17:53Z</updated>
<author>
<name>Daniel Gerzo</name>
<email>danger@FreeBSD.org</email>
</author>
<published>2008-07-06T12:17:53Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=6d05da1dc9937ecdf2933b13954a2fae37da77c7'/>
<id>urn:sha1:6d05da1dc9937ecdf2933b13954a2fae37da77c7</id>
<content type='text'>
PR:		docs/75995
Submitted by:	Tarc &lt;tarc@po.cs.msu.su&gt;
MFC after:	3 days
</content>
</entry>
<entry>
<title>Sort sections.</title>
<updated>2005-01-20T09:17:07Z</updated>
<author>
<name>Ruslan Ermilov</name>
<email>ru@FreeBSD.org</email>
</author>
<published>2005-01-20T09:17:07Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=24a0682c6465290759ed0b09ea16e40e7cd47053'/>
<id>urn:sha1:24a0682c6465290759ed0b09ea16e40e7cd47053</id>
<content type='text'>
</content>
</entry>
<entry>
<title>mdoc(7): Use the new feature of the .In macro.</title>
<updated>2003-09-08T19:57:22Z</updated>
<author>
<name>Ruslan Ermilov</name>
<email>ru@FreeBSD.org</email>
</author>
<published>2003-09-08T19:57:22Z</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=fe08efe680f6705e0c60beabe3e39629c655e743'/>
<id>urn:sha1:fe08efe680f6705e0c60beabe3e39629c655e743</id>
<content type='text'>
</content>
</entry>
</feed>
