X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=phpstr%2Fphpstr.h;h=259cab2b9def7feb619d6519dae51070a0bb3540;hb=b46b6f8c9261ed2b7c5198169073b0ed18a9c4f5;hp=9b6628e75a7bb1b92059fd13871463d358559b66;hpb=5685b2140c8948fe617766ce154bb7462729ea6f;p=m6w6%2Fext-http diff --git a/phpstr/phpstr.h b/phpstr/phpstr.h index 9b6628e..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) \ { \ @@ -68,15 +70,16 @@ RETVAL_STRINGL((STR)->data, (STR)->used, (dup)); \ FREE_PHPSTR((free), (STR)); -typedef struct { - size_t size; +typedef struct _phpstr_t { char *data; size_t used; size_t free; - int pmem; + size_t size; + unsigned pmem:1; + unsigned reserved:31; } phpstr; -typedef enum { +typedef enum _phpstr_free_t { PHPSTR_FREE_NOT = 0, PHPSTR_FREE_PTR, /* pefree() */ PHPSTR_FREE_VAL, /* phpstr_dtor() */ @@ -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);