mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-13 17:00:19 +00:00
Add mg_strfree()
CL: Add mg_strfree() PUBLISHED_FROM=b80566218986e0607a9d2758bf776a1031b27212
This commit is contained in:
1 parent
c431904b56
commit
69e2b2985d
2 files changed
+13
No files matched your search
@@ -1774,6 +1774,14 @@ int mg_strncmp(const struct mg_str str1, const struct mg_str str2, size_t n) {
|
|||||||
return mg_strcmp(s1, s2);
|
return mg_strcmp(s1, s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mg_strfree(struct mg_str *s) WEAK;
|
||||||
|
void mg_strfree(struct mg_str *s) {
|
||||||
|
char *sp = (char *) s->p;
|
||||||
|
s->p = NULL;
|
||||||
|
s->len = 0;
|
||||||
|
if (sp != NULL) free(sp);
|
||||||
|
}
|
||||||
|
|
||||||
const char *mg_strstr(const struct mg_str haystack,
|
const char *mg_strstr(const struct mg_str haystack,
|
||||||
const struct mg_str needle) WEAK;
|
const struct mg_str needle) WEAK;
|
||||||
const char *mg_strstr(const struct mg_str haystack,
|
const char *mg_strstr(const struct mg_str haystack,
|
||||||
|
|||||||
@@ -2280,6 +2280,11 @@ int mg_strcmp(const struct mg_str str1, const struct mg_str str2);
|
|||||||
*/
|
*/
|
||||||
int mg_strncmp(const struct mg_str str1, const struct mg_str str2, size_t n);
|
int mg_strncmp(const struct mg_str str1, const struct mg_str str2, size_t n);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free the string (assuming it was heap allocated).
|
||||||
|
*/
|
||||||
|
void mg_strfree(struct mg_str *s);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finds the first occurrence of a substring `needle` in the `haystack`.
|
* Finds the first occurrence of a substring `needle` in the `haystack`.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in new issue
Block a user