mirror of
https://github.com/lxsang/ant-http
synced 2025-07-15 05:19:55 +02:00
fix memory leak bug
This commit is contained in:
@ -81,11 +81,11 @@ char* __s(const char* fstring,...)
|
||||
*/
|
||||
void trim(char* str, const char delim)
|
||||
{
|
||||
if(!str) return;
|
||||
if(!str || strlen(str) == 0) return;
|
||||
char * p = str;
|
||||
int l = strlen(p);
|
||||
|
||||
while(p[l - 1] == delim) p[--l] = 0;
|
||||
while(l > 0 && p[l - 1] == delim)
|
||||
p[--l] = 0;
|
||||
while(* p && (* p) == delim ) ++p, --l;
|
||||
memmove(str, p, l + 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user