Use realloc in nghttp2_reserve_buffer

This commit is contained in:
Tatsuhiro Tsujikawa 2013-07-16 22:22:57 +09:00
parent a3bdda68f8
commit f9911a6251
1 changed files with 1 additions and 2 deletions

View File

@ -60,11 +60,10 @@ int nghttp2_reserve_buffer(uint8_t **buf_ptr, size_t *buflen_ptr,
if(min_length > *buflen_ptr) { if(min_length > *buflen_ptr) {
uint8_t *temp; uint8_t *temp;
min_length = (min_length+4095)/4096*4096; min_length = (min_length+4095)/4096*4096;
temp = malloc(min_length); temp = realloc(*buf_ptr, min_length);
if(temp == NULL) { if(temp == NULL) {
return NGHTTP2_ERR_NOMEM; return NGHTTP2_ERR_NOMEM;
} else { } else {
free(*buf_ptr);
*buf_ptr = temp; *buf_ptr = temp;
*buflen_ptr = min_length; *buflen_ptr = min_length;
} }