aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/hcreate.3
Commit message (Collapse)AuthorAgeFilesLines
* hcreate(3): fix incorrect claim that hdestroy frees keysKit Dallege2026-06-101-5/+6
| | | | | | | | | | | | | | | | 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 <xaum.io@gmail.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/2095
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
* hcreate(3): fix the ERRORS section and bump .DdEnji Cooper2017-02-071-4/+4
| | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=313374
* Replace implementation of hsearch() by one that scales.Ed Schouten2015-12-271-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=292767
* Add re-entrant versions of the hash functions based on the GNU api.Pedro F. Giffuni2014-07-211-12/+81
| | | | | | | | | | 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) Notes: svn path=/head/; revision=268943
* mdoc: order prologue macros consistently by Dd/Dt/OsUlrich Spörlein2010-04-141-1/+1
| | | | | | | | | | | 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) Notes: svn path=/head/; revision=206622
* - This code was intially obtained from NetBSD, but it's missing licenceDaniel Gerzo2008-07-061-1/+29
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=180329
* - Add description about a missing return valueDaniel Gerzo2008-07-061-2/+6
| | | | | | | | | PR: docs/75995 Submitted by: Tarc <tarc@po.cs.msu.su> MFC after: 3 days Notes: svn path=/head/; revision=180325
* Sort sections.Ruslan Ermilov2005-01-201-10/+10
| | | | Notes: svn path=/head/; revision=140505
* mdoc(7): Use the new feature of the .In macro.Ruslan Ermilov2003-09-081-1/+1
| | | | Notes: svn path=/head/; revision=119893
* Document the fact that hdestory calls free on the keys added withDavid Malone2003-03-121-5/+25
| | | | | | | | | | hsearch(.., ENTER). Make the example reflect this. PR: 49951 Submitted by: Peter Jeremy <peterjeremy@optushome.com.au> Notes: svn path=/head/; revision=112143
* mdoc(7) police: eliminate -ww warnings.Ruslan Ermilov2001-07-091-2/+2
| | | | Notes: svn path=/head/; revision=79461
* Add new, from scratch implementation of hsearch() et al that actually works.Ruslan Ermilov2001-05-151-0/+206
Obtained from: NetBSD MFC after: 1 month Notes: svn path=/head/; revision=76613