Exemplo n.º 1
0
static void* crypto_realloc(void* ptr, size_t size CCB_FILE_LINE_ARGS)
{
    void* ret = enif_realloc(ptr, size);

    if (!ret && size)
	nomem(size, "reallocate");
    return ret;
}
Exemplo n.º 2
0
static inline void resize_buf(ErlNifEnv* env, int buf_len, struct buf *rbuf, int len_to_add)
{
    int new_len = rbuf->len + len_to_add;
    if (new_len >= rbuf->limit) {
        rbuf->limit = ((new_len / buf_len) + 1) * buf_len;
        rbuf->b = enif_realloc(rbuf->b, rbuf->limit);
    };
}
static void add_element(state_t *st, ERL_NIF_TERM t)
{
  container_t *c = st->c;
  if (c != NULL) {
    if (c->count >= c->arraysz) {
      c->arraysz *= 2;
      c->array = enif_realloc(st->env, c->array, c->arraysz);
    }
    if (st->key) {
      /* the previous stored element was a key, so replace the entry
         with a key/value pair, and don't count it twice */
      c->array[c->count-1] = enif_make_tuple2(st->env,
                                              c->array[c->count-1],
                                              t);
      st->key = 0;
    } else {
      c->array[c->count] = t;
      ++(c->count);
    }
  }
}
static void *realloc_func(void *ctx, void *ptr, unsigned int sz)
{
  return enif_realloc((ErlNifEnv *)ctx, ptr, sz);
}
Exemplo n.º 5
0
static void *
gmperl_reallocate(void *ptr, size_t old_size, size_t new_size)
{
    return enif_realloc(ptr, new_size);
}