projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
- no empty_string anymore
[m6w6/ext-http]
/
phpstr
/
phpstr.c
diff --git
a/phpstr/phpstr.c
b/phpstr/phpstr.c
index 999230005bdf15c94d40e84cb8f511ae40678bcf..286a190b3669119dd146118a56ced262b18a9ec3 100644
(file)
--- a/
phpstr/phpstr.c
+++ b/
phpstr/phpstr.c
@@
-5,26
+5,26
@@
#include "phpstr.h"
#ifndef PHPSTR_DEFAULT_SIZE
#include "phpstr.h"
#ifndef PHPSTR_DEFAULT_SIZE
-#define PHPSTR_DEFAULT_SIZE
409
6
+#define PHPSTR_DEFAULT_SIZE
25
6
#endif
PHPSTR_API phpstr *phpstr_init_ex(phpstr *buf, size_t chunk_size, zend_bool pre_alloc)
{
if (!buf) {
#endif
PHPSTR_API phpstr *phpstr_init_ex(phpstr *buf, size_t chunk_size, zend_bool pre_alloc)
{
if (!buf) {
- buf = e
calloc(1,
sizeof(phpstr));
+ buf = e
malloc(
sizeof(phpstr));
}
}
- buf->used = 0;
buf->size = chunk_size > 0 ? chunk_size : PHPSTR_DEFAULT_SIZE;
buf->size = chunk_size > 0 ? chunk_size : PHPSTR_DEFAULT_SIZE;
- buf->free = pre_alloc ? buf->size : 0;
buf->data = pre_alloc ? emalloc(buf->size) : NULL;
buf->data = pre_alloc ? emalloc(buf->size) : NULL;
+ buf->free = pre_alloc ? buf->size : 0;
+ buf->used = 0;
return buf;
}
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, c
onst c
har *string, size_t length)
{
{
- buf = phpstr_init(buf);
+
buf = phpstr_init(buf);
phpstr_append(buf, string, length);
return buf;
}
phpstr_append(buf, string, length);
return buf;
}
@@
-139,10
+139,10
@@
PHPSTR_API phpstr *phpstr_dup(const phpstr *buf)
return dup;
}
return dup;
}
-PHPSTR_API s
s
ize_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) {
{
if (offset >= buf->used) {
- return
-1
;
+ return
0
;
}
if (offset + length > buf->used) {
length = buf->used - offset;
}
if (offset + length > buf->used) {
length = buf->used - offset;
@@
-230,7
+230,7
@@
PHPSTR_API int phpstr_cmp(phpstr *left, phpstr *right)
}
}
}
}
-PHPSTR_API void phpstr_
free
(phpstr *buf)
+PHPSTR_API void phpstr_
dtor
(phpstr *buf)
{
if (buf->data) {
efree(buf->data);
{
if (buf->data) {
efree(buf->data);
@@
-240,10
+240,10
@@
PHPSTR_API void phpstr_free(phpstr *buf)
buf->free = 0;
}
buf->free = 0;
}
-PHPSTR_API void phpstr_
dtor
(phpstr *buf)
+PHPSTR_API void phpstr_
free
(phpstr *buf)
{
if (buf) {
{
if (buf) {
- phpstr_
free
(buf);
+ phpstr_
dtor
(buf);
efree(buf);
}
}
efree(buf);
}
}