mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-01 19:46:36 +03:00
adds and uses c3_realloc()
This commit is contained in:
parent
a3bef0f23a
commit
76fbb1d918
@ -97,3 +97,12 @@
|
||||
void* rut = c3_malloc(s); \
|
||||
memset(rut, 0, s); \
|
||||
rut;})
|
||||
|
||||
/* c3_realloc(): asserting realloc
|
||||
*/
|
||||
#define c3_realloc(a, b) ({ \
|
||||
void* rut = realloc(a, b); \
|
||||
if ( 0 == rut ) { \
|
||||
c3_assert(!"memory lost"); \
|
||||
} \
|
||||
rut;})
|
||||
|
@ -14,12 +14,7 @@ static size_t
|
||||
_dawn_curl_alloc(void* dat_v, size_t uni_t, size_t mem_t, uv_buf_t* buf_u)
|
||||
{
|
||||
size_t siz_t = uni_t * mem_t;
|
||||
buf_u->base = realloc(buf_u->base, 1 + siz_t + buf_u->len);
|
||||
|
||||
if ( 0 == buf_u->base ) {
|
||||
fprintf(stderr, "out of memory\n");
|
||||
u3_lo_bail();
|
||||
}
|
||||
buf_u->base = c3_realloc(buf_u->base, 1 + siz_t + buf_u->len);
|
||||
|
||||
memcpy(buf_u->base + buf_u->len, dat_v, siz_t);
|
||||
buf_u->len += siz_t;
|
||||
|
@ -2687,9 +2687,7 @@ _proxy_peek_read_cb(uv_stream_t* don_u,
|
||||
}
|
||||
else {
|
||||
c3_w len_w = siz_w + con_u->buf_u.len;
|
||||
// XX c3_realloc
|
||||
void* ptr_v = realloc(con_u->buf_u.base, len_w);
|
||||
c3_assert( 0 != ptr_v );
|
||||
void* ptr_v = c3_realloc(con_u->buf_u.base, len_w);
|
||||
|
||||
memcpy(ptr_v + con_u->buf_u.len, buf_u->base, siz_w);
|
||||
con_u->buf_u = uv_buf_init(ptr_v, len_w);
|
||||
|
Loading…
Reference in New Issue
Block a user