Skip to content

Commit f330051

Browse files
committed
Update long usage in regex polyfill
1 parent 96c92ef commit f330051

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

win32/regexec.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
231231
pbytes = sizeof(*reach_pos) * tnfa->num_states;
232232
xbytes = sizeof(regoff_t) * num_tags;
233233
total_bytes =
234-
(sizeof(long) - 1) * 4 /* for alignment paddings */
234+
(sizeof(size_t) - 1) * 4 /* for alignment paddings */
235235
+ (rbytes + xbytes * tnfa->num_states) * 2 + tbytes + pbytes;
236236

237237
/* Allocate the memory. */
@@ -242,16 +242,16 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
242242
/* Get the various pointers within tmp_buf (properly aligned). */
243243
tmp_tags = (void *)buf;
244244
tmp_buf = buf + tbytes;
245-
tmp_buf += ALIGN(tmp_buf, long);
245+
tmp_buf += ALIGN(tmp_buf, size_t);
246246
reach_next = (void *)tmp_buf;
247247
tmp_buf += rbytes;
248-
tmp_buf += ALIGN(tmp_buf, long);
248+
tmp_buf += ALIGN(tmp_buf, size_t);
249249
reach = (void *)tmp_buf;
250250
tmp_buf += rbytes;
251-
tmp_buf += ALIGN(tmp_buf, long);
251+
tmp_buf += ALIGN(tmp_buf, size_t);
252252
reach_pos = (void *)tmp_buf;
253253
tmp_buf += pbytes;
254-
tmp_buf += ALIGN(tmp_buf, long);
254+
tmp_buf += ALIGN(tmp_buf, size_t);
255255
for (i = 0; i < tnfa->num_states; i++)
256256
{
257257
reach[i].tags = (void *)tmp_buf;

win32/tre-mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block,
143143
}
144144

145145
/* Make sure the next pointer will be aligned. */
146-
size += ALIGN(mem->ptr + size, long);
146+
size += ALIGN(mem->ptr + size, size_t);
147147

148148
/* Allocate from current block. */
149149
ptr = mem->ptr;

win32/tre.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <regex.h>
3333
#include <wchar.h>
3434
#include <wctype.h>
35+
#include <stdint.h>
3536

3637
#undef TRE_MBSTATE
3738

@@ -77,8 +78,8 @@ typedef wctype_t tre_ctype_t;
7778
/* Returns number of bytes to add to (char *)ptr to make it
7879
properly aligned for the type. */
7980
#define ALIGN(ptr, type) \
80-
((((long)ptr) % sizeof(type)) \
81-
? (sizeof(type) - (((long)ptr) % sizeof(type))) \
81+
((((uintptr_t)ptr) % sizeof(type)) \
82+
? (sizeof(type) - (((uintptr_t)ptr) % sizeof(type))) \
8283
: 0)
8384

8485
#undef MAX

0 commit comments

Comments
 (0)