projects
/
p5sagit/p5-mst-13.2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
(parent:
dc57de0
)
In strftime(), save a malloc()/free() by using sv_usepvn_flags().
Nicholas Clark [Thu, 15 Oct 2009 15:26:51 +0000 (16:26 +0100)]
ext/POSIX/POSIX.xs
patch
|
blob
|
blame
|
history
diff --git
a/ext/POSIX/POSIX.xs
b/ext/POSIX/POSIX.xs
index
b3a64a7
..
8572367
100644
(file)
--- a/
ext/POSIX/POSIX.xs
+++ b/
ext/POSIX/POSIX.xs
@@
-1795,8
+1795,12
@@
strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
{
char *buf = my_strftime(SvPV_nolen(fmt), sec, min, hour, mday, mon, year, wday, yday, isdst);
if (buf) {
- ST(0) = newSVpvn_flags(buf, strlen(buf), SVs_TEMP | SvUTF8(fmt));
- Safefree(buf);
+ SV *const sv = sv_newmortal();
+ sv_usepvn_flags(sv, buf, strlen(buf), SV_HAS_TRAILING_NUL);
+ if (SvUTF8(fmt)) {
+ SvUTF8_on(sv);
+ }
+ ST(0) = sv;
}
}