#include "php.h"
#include "phpstr.h"
-#ifndef PHPSTR_DEFAULT_SIZE
-#define PHPSTR_DEFAULT_SIZE 256
-#endif
-
PHPSTR_API phpstr *phpstr_init_ex(phpstr *buf, size_t chunk_size, zend_bool pre_alloc)
{
if (!buf) {
PHPSTR_API void phpstr_dtor(phpstr *buf)
{
- if (buf->data) {
- efree(buf->data);
- buf->data = NULL;
- }
+ STR_SET(buf->data, NULL);
buf->used = 0;
buf->free = 0;
}
-PHPSTR_API void phpstr_free(phpstr *buf)
+PHPSTR_API void phpstr_free(phpstr **buf)
{
- if (buf) {
- phpstr_dtor(buf);
- efree(buf);
+ if (*buf) {
+ phpstr_dtor(*buf);
+ efree(*buf);
+ *buf = NULL;
}
}