simplehash: Undefine SH_RAW_ALLOCATOR after inclusion

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: simplehash: Undefine SH_RAW_ALLOCATOR after inclusion
Date: 2026-11-23 08:26:34
Message-ID: 6658AC8F-3AC7-4D93-811B-92F6853D3B72@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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/

Attachment Content-Type Size
v1-0001-simplehash-Undefine-SH_RAW_ALLOCATOR-after-inclus.patch application/octet-stream 1.0 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Nidzwetzki 2026-11-23 08:49:30 Re: [PATCH] Fix PITR pause bypass when initial XLOG_RUNNING_XACTS has subxid overflow
Previous Message Andrey Borodin 2026-11-23 07:47:31 Re: [PATCH 0/2] Parallelizing the archiver