예제 #1
0
파일: buffer.c 프로젝트: henteko/bossan
buffer_result
write2buf(buffer *buf, const char *c, size_t l)
{
  size_t newl;
  char *newbuf;
  buffer_result ret = WRITE_OK;
  newl = buf->len + l;
    
  if (newl >= buf->buf_size) {
    buf->buf_size *= 2;
    if(buf->buf_size <= newl) {
      buf->buf_size = (int)(newl + 1);
    }
    if(buf->buf_size > buf->limit){
      buf->buf_size = buf->limit + 1;
    }
    newbuf = (char*)ruby_xrealloc(buf->buf, buf->buf_size);
    buf->buf = newbuf;
  }
  if(newl >= buf->buf_size){
    l = buf->buf_size - buf->len -1;
    ret = LIMIT_OVER;
  }
  memcpy(buf->buf + buf->len, c , l);
  buf->len += (int)l;
  return ret;
}
예제 #2
0
파일: wsf_util.c 프로젝트: harunjuhasz/wsf
static void *WSF_CALL
wsf_realloc_warpper (
    axutil_allocator_t * allocator,
    void *ptr,
    size_t size)
{
    return ruby_xrealloc(ptr, size);
}
예제 #3
0
파일: fiddle.c 프로젝트: Danylyuk/first_app
/*
 * call-seq: Fiddle.realloc(addr, size)
 *
 * Change the size of the memory allocated at the memory location +addr+ to
 * +size+ bytes.  Returns the memory address of the reallocated memory, which
 * may be different than the address passed in.
 */
static VALUE
rb_fiddle_realloc(VALUE self, VALUE addr, VALUE size)
{
    void *ptr = NUM2PTR(addr);

    ptr = (void*)ruby_xrealloc(ptr, NUM2INT(size));
    return PTR2NUM(ptr);
}
예제 #4
0
파일: gc.c 프로젝트: 1nueve/MacRuby
void *
ruby_xrealloc2(void *ptr, size_t n, size_t size)
{
    size_t len = size * n;
    if (n != 0 && size != len / n) {
	rb_raise(rb_eArgError, "realloc: possible integer overflow");
    }
    return ruby_xrealloc(ptr, len);
}
예제 #5
0
파일: dl.c 프로젝트: AeonSaber/first_app
/*
 * call-seq: DL.realloc(addr, size)
 *
 * Change the size of the memory allocated at the memory location +addr+ to
 * +size+ bytes.  Returns the memory address of the reallocated memory, which
 * may be different than the address passed in.
 */
VALUE
rb_dl_realloc(VALUE self, VALUE addr, VALUE size)
{
    void *ptr = NUM2PTR(addr);

    rb_secure(4);
    ptr = (void*)ruby_xrealloc(ptr, NUM2INT(size));
    return PTR2NUM(ptr);
}