Skip to content

Commit

Permalink
Replace usage of long with size_t in memory allocation functions.
Browse files Browse the repository at this point in the history
Improve compatibility of `ruby_xrealloc`. Fixes #220.
  • Loading branch information
ioquatix committed Sep 24, 2019
1 parent a0b368f commit f171273
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ext/libev/ev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ ev_syserr (const char *msg)
}

static void *
ev_realloc_emul (void *ptr, long size) EV_NOEXCEPT
ev_realloc_emul (void *ptr, size_t size) EV_NOEXCEPT
{
/* some systems, notably openbsd and darwin, fail to properly
* implement realloc (x, 0) (as required by both ansi c-89 and
Expand All @@ -1762,17 +1762,17 @@ ev_realloc_emul (void *ptr, long size) EV_NOEXCEPT
return 0;
}

static void *(*alloc)(void *ptr, long size) EV_NOEXCEPT = ev_realloc_emul;
static void *(*alloc)(void *ptr, size_t size) EV_NOEXCEPT = ev_realloc_emul;

ecb_cold
void
ev_set_allocator (void *(*cb)(void *ptr, long size) EV_NOEXCEPT) EV_NOEXCEPT
ev_set_allocator (void *(*cb)(void *ptr, size_t size) EV_NOEXCEPT) EV_NOEXCEPT
{
alloc = cb;
}

inline_speed void *
ev_realloc (void *ptr, long size)
ev_realloc (void *ptr, size_t size)
{
ptr = alloc (ptr, size);

Expand Down
2 changes: 1 addition & 1 deletion ext/libev/ev.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ EV_API_DECL void ev_sleep (ev_tstamp delay) EV_NOEXCEPT; /* sleep for a while */
* or take some potentially destructive action.
* The default is your system realloc function.
*/
EV_API_DECL void ev_set_allocator (void *(*cb)(void *ptr, long size) EV_NOEXCEPT) EV_NOEXCEPT;
EV_API_DECL void ev_set_allocator (void *(*cb)(void *ptr, size_t size) EV_NOEXCEPT) EV_NOEXCEPT;

/* set the callback function to call on a
* retryable syscall error
Expand Down

0 comments on commit f171273

Please sign in to comment.