This is a first step in avoiding to constantly reinitialize chunks.
It replaces the old chunk_reset() which was not properly named as it
used to drop everything and was only used by chunk_destroy(). It has
been renamed chunk_drop().
int chunk_strcmp(const struct chunk *chk, const char *str);
int chunk_strcasecmp(const struct chunk *chk, const char *str);
+static inline void chunk_reset(struct chunk *chk)
+{
+ chk->len = 0;
+}
+
static inline void chunk_init(struct chunk *chk, char *str, size_t size)
{
chk->str = str;
return 1;
}
-static inline void chunk_reset(struct chunk *chk)
+static inline void chunk_drop(struct chunk *chk)
{
chk->str = NULL;
chk->len = -1;
if (!chk->size)
return;
- if (chk->str)
- free(chk->str);
-
- chunk_reset(chk);
+ free(chk->str);
+ chunk_drop(chk);
}
/*