pbytes = sizeof(*reach_pos) * tnfa->num_states;
xbytes = sizeof(regoff_t) * num_tags;
total_bytes =
- (sizeof(long) - 1) * 4 /* for alignment paddings */
+ (sizeof(size_t) - 1) * 4 /* for alignment paddings */
+ (rbytes + xbytes * tnfa->num_states) * 2 + tbytes + pbytes;
/* Allocate the memory. */
/* Get the various pointers within tmp_buf (properly aligned). */
tmp_tags = (void *)buf;
tmp_buf = buf + tbytes;
- tmp_buf += ALIGN(tmp_buf, long);
+ tmp_buf += ALIGN(tmp_buf, size_t);
reach_next = (void *)tmp_buf;
tmp_buf += rbytes;
- tmp_buf += ALIGN(tmp_buf, long);
+ tmp_buf += ALIGN(tmp_buf, size_t);
reach = (void *)tmp_buf;
tmp_buf += rbytes;
- tmp_buf += ALIGN(tmp_buf, long);
+ tmp_buf += ALIGN(tmp_buf, size_t);
reach_pos = (void *)tmp_buf;
tmp_buf += pbytes;
- tmp_buf += ALIGN(tmp_buf, long);
+ tmp_buf += ALIGN(tmp_buf, size_t);
for (i = 0; i < tnfa->num_states; i++)
{
reach[i].tags = (void *)tmp_buf;
}
/* Make sure the next pointer will be aligned. */
- size += ALIGN(mem->ptr + size, long);
+ size += ALIGN(mem->ptr + size, size_t);
/* Allocate from current block. */
ptr = mem->ptr;
#include <regex.h>
#include <wchar.h>
#include <wctype.h>
+#include <stdint.h>
#undef TRE_MBSTATE
/* Returns number of bytes to add to (char *)ptr to make it
properly aligned for the type. */
#define ALIGN(ptr, type) \
- ((((long)ptr) % sizeof(type)) \
- ? (sizeof(type) - (((long)ptr) % sizeof(type))) \
+ ((((uintptr_t)ptr) % sizeof(type)) \
+ ? (sizeof(type) - (((uintptr_t)ptr) % sizeof(type))) \
: 0)
#undef MAX