X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_buffer.c;h=ef0abcd067f7c186953f81e78f64d61ba8dfbc82;hp=bd99dc84f1677ce2a766b2c215796691719c7117;hb=9de008496a220c769a745cd1eead0a3b3d7d6cca;hpb=66f7e8b6b937976c9c1d3dbfb86a90141b19b5c6 diff --git a/php_http_buffer.c b/php_http_buffer.c index bd99dc8..ef0abcd 100644 --- a/php_http_buffer.c +++ b/php_http_buffer.c @@ -72,6 +72,19 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(php_http_buffer_t *buf, siz return 0; } +PHP_HTTP_BUFFER_API char *php_http_buffer_account(php_http_buffer_t *buf, size_t to_account) +{ + /* it's probably already too late but check anyway */ + if (to_account > buf->free) { + return NULL; + } + + buf->free -= to_account; + buf->used += to_account; + + return buf->data + buf->used; +} + PHP_HTTP_BUFFER_API size_t php_http_buffer_shrink(php_http_buffer_t *buf) { /* avoid another realloc on fixation */