X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=phpstr%2Fphpstr.h;h=259cab2b9def7feb619d6519dae51070a0bb3540;hb=ebf03950ffaea849b931adf83b6c20ac9fb7ef33;hp=295ba3c1402c3f92388d83d6da97a51b6c052d9a;hpb=ccd556e32e7264830790ec13b72a9b0e3760684b;p=m6w6%2Fext-http diff --git a/phpstr/phpstr.h b/phpstr/phpstr.h index 295ba3c..259cab2 100644 --- a/phpstr/phpstr.h +++ b/phpstr/phpstr.h @@ -10,6 +10,8 @@ # define PHPSTR_DEFAULT_SIZE 256 #endif +#define PHPSTR_NOMEM ((size_t) -1) + #ifndef STR_SET # define STR_SET(STR, SET) \ { \ @@ -69,11 +71,12 @@ FREE_PHPSTR((free), (STR)); typedef struct _phpstr_t { - size_t size; char *data; size_t used; size_t free; - int pmem; + size_t size; + unsigned pmem:1; + unsigned reserved:31; } phpstr; typedef enum _phpstr_free_t { @@ -104,8 +107,8 @@ PHPSTR_API phpstr *phpstr_init_ex(phpstr *buf, size_t chunk_size, int flags); PHPSTR_API phpstr *phpstr_from_string_ex(phpstr *buf, const char *string, size_t length); /* usually only called from within the internal functions */ -#define phpstr_resize(b, s) phpstr_resize_ex((b), (s), 0) -PHPSTR_API size_t phpstr_resize_ex(phpstr *buf, size_t len, size_t override_size); +#define phpstr_resize(b, s) phpstr_resize_ex((b), (s), 0, 0) +PHPSTR_API size_t phpstr_resize_ex(phpstr *buf, size_t len, size_t override_size, int allow_error); /* shrink memory chunk to actually used size (+1) */ PHPSTR_API size_t phpstr_shrink(phpstr *buf);