]> git.ipfire.org Git - thirdparty/git.git/blobdiff - kwset.c
Merge branch 'sr/gpg-interface-stop-at-the-end'
[thirdparty/git.git] / kwset.c
diff --git a/kwset.c b/kwset.c
index 4fb6455acaf1293c4f47f27eb6e47be4d39633e2..fc439e0667f137f3449635a37a32f8418d5041f0 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))
@@ -475,7 +481,7 @@ kwsprep (kwset_t kws)
        for (i = 0; i < NCHAR; ++i)
          kwset->next[i] = next[U(trans[i])];
       else
-       memcpy(kwset->next, next, NCHAR * sizeof(struct trie *));
+       COPY_ARRAY(kwset->next, next, NCHAR);
     }
 
   /* Fix things up for any translation table. */