Skip to content

Commit c715967

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
kwset: allow building with GCC 8
The kwset functionality makes use of the obstack code, which expects to be handed a function that can allocate large chunks of data. It expects that function to accept a `size` parameter of type `long`. This upsets GCC 8 on Windows, because `long` does not have the same bit size as `size_t` there. Now, the proper thing to do would be to switch to `size_t`. But this would make us deviate from the "upstream" code even further, making it hard to synchronize with newer versions, and also it would be quite involved because that `long` type is so invasive in that code. Let's punt, and instead provide a super small wrapper around `xmalloc()`. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b0b2171 commit c715967

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

kwset.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@
3838
#include "compat/obstack.h"
3939

4040
#define NCHAR (UCHAR_MAX + 1)
41-
#define obstack_chunk_alloc xmalloc
41+
/* adapter for `xmalloc()`, which takes `size_t`, not `long` */
42+
static void *obstack_chunk_alloc(long size)
43+
{
44+
if (size < 0)
45+
BUG("Cannot allocate a negative amount: %ld", size);
46+
return xmalloc(size);
47+
}
4248
#define obstack_chunk_free free
4349

4450
#define U(c) ((unsigned char) (c))

0 commit comments

Comments
 (0)