X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=phpstr%2Fphpstr.c;h=286a190b3669119dd146118a56ced262b18a9ec3;hb=2253ca28b6a5699a8e2d62a0458ced3cb7a3107a;hp=af090fa02d16aadb2d1139e9c3f3ba9e168d7175;hpb=af674f03c32f0f56b7f8c67e61c7e86b3ea23be5;p=m6w6%2Fext-http diff --git a/phpstr/phpstr.c b/phpstr/phpstr.c index af090fa..286a190 100644 --- a/phpstr/phpstr.c +++ b/phpstr/phpstr.c @@ -11,7 +11,7 @@ PHPSTR_API phpstr *phpstr_init_ex(phpstr *buf, size_t chunk_size, zend_bool pre_alloc) { if (!buf) { - buf = ecalloc(1, sizeof(phpstr)); + buf = emalloc(sizeof(phpstr)); } buf->size = chunk_size > 0 ? chunk_size : PHPSTR_DEFAULT_SIZE; @@ -22,7 +22,7 @@ PHPSTR_API phpstr *phpstr_init_ex(phpstr *buf, size_t chunk_size, zend_bool pre_ return buf; } -PHPSTR_API phpstr *phpstr_from_string_ex(phpstr *buf, char *string, size_t length) +PHPSTR_API phpstr *phpstr_from_string_ex(phpstr *buf, const char *string, size_t length) { buf = phpstr_init(buf); phpstr_append(buf, string, length); @@ -139,10 +139,10 @@ PHPSTR_API phpstr *phpstr_dup(const phpstr *buf) return dup; } -PHPSTR_API ssize_t phpstr_cut(phpstr *buf, size_t offset, size_t length) +PHPSTR_API size_t phpstr_cut(phpstr *buf, size_t offset, size_t length) { if (offset >= buf->used) { - return -1; + return 0; } if (offset + length > buf->used) { length = buf->used - offset;