Skip to content

Commit

Permalink
better use Newx/Safefree?
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenichi Ishigaki authored and Kenichi Ishigaki committed Feb 22, 2010
1 parent dd19ea8 commit 15cb57f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions XS.xs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static char* url_decode(const char* s, size_t len)
return (char*)s;

NEEDS_DECODE:
dbuf = malloc(len - 1);
Newx(dbuf, len - 1, char);
assert(dbuf != NULL);
memcpy(dbuf, s, i);
d = dbuf + i;
Expand All @@ -67,7 +67,7 @@ static char* url_decode(const char* s, size_t len)
int hi, lo;
if ((hi = hex_decode(s[i + 1])) == -1
|| (lo = hex_decode(s[i + 2])) == -1) {
free(dbuf);
Safefree(dbuf);
return NULL;
}
*d++ = hi * 16 + lo;
Expand All @@ -90,7 +90,7 @@ __inline int store_url_decoded(HV* env, const char* name, size_t name_len,
hv_store(env, name, name_len, newSVpvn(value, value_len), 0);
else {
hv_store(env, name, name_len, newSVpv(decoded, 0), 0);
free(decoded);
Safefree(decoded);
}
return 0;
}
Expand Down

0 comments on commit 15cb57f

Please sign in to comment.