unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/5] xap_helper.h: strdup keys for DragonFlyBSD hdestroy(3)
Date: Fri,  6 Oct 2023 09:46:01 +0000	[thread overview]
Message-ID: <20231006094604.95809-3-e@80x24.org> (raw)
In-Reply-To: <20231006094604.95809-1-e@80x24.org>

DragonFlyBSD matches OpenBSD behavior in freeing every single key on
hdestroy(3).  I suppose hdestroy(3) is neglected enough these days that
nobody cares and we'll likely introduce a small C hash table such as
khash (also used within git).
---
 lib/PublicInbox/xap_helper.h | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h
index a78a3f76..3fa615a5 100644
--- a/lib/PublicInbox/xap_helper.h
+++ b/lib/PublicInbox/xap_helper.h
@@ -491,11 +491,20 @@ static enum exc_iter dump_roots_iter(struct req *req,
 
 static char *hsearch_enter_key(char *s)
 {
-#if defined(__OpenBSD__) /* hdestroy frees each key */
+#if defined(__OpenBSD__) || defined(__DragonFly__)
+	// hdestroy frees each key on some platforms,
+	// so give it something to free:
 	char *ret = strdup(s);
 	if (!ret) perror("strdup");
 	return ret;
-#endif // glibc, musl, FreeBSD, NetBSD do not free keys
+// AFAIK there's no way to detect musl, assume non-glibc Linux is musl:
+#elif defined(__GLIBC__) || defined(__linux__) || \
+	defined(__FreeBSD__) || defined(__NetBSD__)
+	// do nothing on these platforms
+#else
+#warning untested platform detected, unsure if hdestroy(3) frees keys
+#warning contact us at meta@public-inbox.org if you get segfaults
+#endif
 	return s;
 }
 

  parent reply	other threads:[~2023-10-06  9:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06  9:45 [PATCH 0/5] Dragonfly BSD support Eric Wong
2023-10-06  9:46 ` [PATCH 1/5] kqnotify: drop EV_CLEAR (edge triggering) Eric Wong
2023-10-06  9:46 ` Eric Wong [this message]
2023-10-06  9:46 ` [PATCH 3/5] devel/sysdefs-list: show more info regardless of OS Eric Wong
2023-10-06  9:46 ` [PATCH 4/5] t/dir_idle: dump event list on failure Eric Wong
2023-10-06  9:46 ` [PATCH 5/5] finalize DragonFlyBSD support Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231006094604.95809-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).