From: Eric Wong Date: Fri, 6 Oct 2023 09:46:01 +0000 (+0000) Subject: xap_helper.h: strdup keys for DragonFlyBSD hdestroy(3) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9230d3903f073e867da597491d885af2c6aa3198;p=thirdparty%2Fpublic-inbox.git xap_helper.h: strdup keys for DragonFlyBSD hdestroy(3) 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). --- diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h index a78a3f769..3fa615a5f 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; }