Update long usage in regex polyfill

This commit is contained in:
Thomas Lam 2021-03-18 08:18:21 -05:00
parent 96c92ef3ee
commit f330051f85
3 changed files with 9 additions and 8 deletions

View File

@ -231,7 +231,7 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
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. */
@ -242,16 +242,16 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
/* 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;

View File

@ -143,7 +143,7 @@ tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block,
}
/* 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;

View File

@ -32,6 +32,7 @@
#include <regex.h>
#include <wchar.h>
#include <wctype.h>
#include <stdint.h>
#undef TRE_MBSTATE
@ -77,8 +78,8 @@ typedef wctype_t tre_ctype_t;
/* 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