Browse Source

Avoid uint64 for 32bit compatibility

Rather than worry about truncation casting from a possibly 64bit value
down to a possibly 32bit size_t we just limit the total bytes per
invocation to 4G using an unsigned integer.

Thanks to @seriyps for the report.

Fixes #61
pull/65/head 0.11.3
Paul J. Davis 11 years ago
parent
commit
99867af6e9
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      c_src/util.c

+ 4
- 1
c_src/util.c View File

@ -31,6 +31,7 @@ get_bytes_per_iter(ErlNifEnv* env, ERL_NIF_TERM val, size_t* bpi)
jiffy_st* st = (jiffy_st*) enif_priv_data(env);
const ERL_NIF_TERM* tuple;
int arity;
unsigned int bytes;
if(!enif_get_tuple(env, val, &arity, &tuple)) {
return 0;
@ -44,10 +45,12 @@ get_bytes_per_iter(ErlNifEnv* env, ERL_NIF_TERM val, size_t* bpi)
return 0;
}
if(!enif_get_uint64(env, tuple[1], bpi)) {
if(!enif_get_uint(env, tuple[1], &bytes)) {
return 0;
}
*bpi = (size_t) bytes;
return 1;
}

Loading…
Cancel
Save