simplehash: Undefine SH_RAW_ALLOCATOR after inclusion

Started by Chao Li1 day ago3 messageshackers
Jump to latest
#1Chao Li
li.evan.chao@gmail.com

Hi,

During an internal company knowledge-sharing session, I spotted a small issue in simplehash.h.

A typical way to define a simple hash table looks like this:
```
/*
* Define a hash table which we can use to store information about the files
* mentioned in the backup manifest.
*/
#define SH_PREFIX manifest_files
#define SH_ELEMENT_TYPE manifest_file
#define SH_KEY_TYPE const char *
#define SH_KEY pathname
#define SH_HASH_KEY(tb, key) hash_string(key)
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
#define SH_SCOPE extern
#define SH_RAW_ALLOCATOR pg_malloc0
#define SH_DEFINE
#include "lib/simplehash.h"
```

At the end of simplehash.h, the macros are undefined so that another hash table can be defined:
```
/* undefine external parameters, so next hash table can be defined */
#undef SH_PREFIX
#undef SH_KEY_TYPE
#undef SH_KEY
#undef SH_ELEMENT_TYPE
#undef SH_HASH_KEY
#undef SH_SCOPE
#undef SH_DECLARE
#undef SH_DEFINE
#undef SH_GET_HASH
#undef SH_STORE_HASH
#undef SH_USE_NONDEFAULT_ALLOCATOR
#undef SH_EQUAL
```

However, SH_RAW_ALLOCATOR is missing from this list.

This trivial patch just adds the missing #undef SH_RAW_ALLOCATOR.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachments:

t259650_1
v1-0001-simplehash-Undefine-SH_RAW_ALLOCATOR-after-inclus.patchapplication/octet-stream; name=v1-0001-simplehash-Undefine-SH_RAW_ALLOCATOR-after-inclus.patch; x-unix-mode=0644Download+1-1
#2Nathan Bossart
nathandbossart@gmail.com
In reply to: Chao Li (#1)
Re: simplehash: Undefine SH_RAW_ALLOCATOR after inclusion

On Mon, Nov 23, 2026 at 04:26:34PM +0800, Chao Li wrote:

This trivial patch just adds the missing #undef SH_RAW_ALLOCATOR.

Committed, thanks.

--
nathan

#3Chao Li
li.evan.chao@gmail.com
In reply to: Nathan Bossart (#2)
Re: simplehash: Undefine SH_RAW_ALLOCATOR after inclusion

On Nov 24, 2026, at 04:11, Nathan Bossart <nathandbossart@gmail.com> wrote:

On Mon, Nov 23, 2026 at 04:26:34PM +0800, Chao Li wrote:

This trivial patch just adds the missing #undef SH_RAW_ALLOCATOR.

Committed, thanks.

--
nathan

Hi Nathan, thanks a lot for committing.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/