NetBSD Problem Report #60953

From www@netbsd.org  Mon Nov  2 05:48:02 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id BB24A1A923B
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  2 Nov 2026 05:48:01 +0000 (UTC)
Message-Id: <20261102054800.694B41A923C@mollari.NetBSD.org>
Date: Mon,  2 Nov 2026 05:48:00 +0000 (UTC)
From: cmhanson@eschatologist.net
Reply-To: cmhanson@eschatologist.net
To: gnats-bugs@NetBSD.org
Subject: FEATURE: libc should have search1/search1_r that take key equality and hash functions
X-Send-Pr-Version: www-1.0
X-From4GNATS: "cmhanson@eschatologist.net via gnats" <gnats-admin@NetBSD.org>

>Number:         60953
>Category:       lib
>Synopsis:       FEATURE: libc should have search1/search1_r that take key equality and hash functions
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 02 05:50:00 +0000 2026
>Originator:     Chris Hanson
>Release:        
>Organization:
N/A
>Environment:
N/A
>Description:
Neither hash table interface in libc (<db.h> or <search.h>) supports an equality comparator, requiring they always use memcmp or strcmp for equality comparisons. Also, the <search.h> hash table interface doesn’t provide a means for specifying the hash function to use for keys.

Since the keys for a <search.h> hash table are anll inserted, found, and removed via the hsearch/hsearch_r functions, it would make sense to provide the equality and hash comparison functions via argument to a hypothetical hsearch1/hsearch1_r.

It would also make sense to provide a “void *context” parameter to such an hsearch1/hsearch1_r function, such that it gets passed to the key hash and equality functions when they’re called, so they can share context with the caller without using a global variable.
>How-To-Repeat:
N/A
>Fix:
N/A

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.