kwset: allow building with GCC 8
[gitweb.git] / kwset.c
diff --git a/kwset.c b/kwset.c
index 4fb6455acaf1293c4f47f27eb6e47be4d39633e2..efc2ff41bc361a7a3bf940b04642ccba8538cb3b 100644 (file)
--- a/kwset.c
+++ b/kwset.c
 #include "compat/obstack.h"
 
 #define NCHAR (UCHAR_MAX + 1)
-#define obstack_chunk_alloc xmalloc
+/* adapter for `xmalloc()`, which takes `size_t`, not `long` */
+static void *obstack_chunk_alloc(long size)
+{
+       if (size < 0)
+               BUG("Cannot allocate a negative amount: %ld", size);
+       return xmalloc(size);
+}
 #define obstack_chunk_free free
 
 #define U(c) ((unsigned char) (c))