summaryrefslogtreecommitdiff
path: root/av.c
diff options
context:
space:
mode:
authorTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commit573fa4ead436f5cdf54e177e876dbef2739a0dac (patch)
treeaf7a91d7c39360778d81e760da21640dca71ac62 /av.c
parent08e6e932beedeeb539d33c0d190f4b39a4ce6d37 (diff)
downloadperl-573fa4ead436f5cdf54e177e876dbef2739a0dac.tar.gz
: reduced malloc patch
(this is the same change as commit 38a1ac3f7341206073b47f38b6bdb094f3f50352, but as applied)
Diffstat (limited to 'av.c')
-rw-r--r--av.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/av.c b/av.c
index 9e94805f68..6b4c03d3e7 100644
--- a/av.c
+++ b/av.c
@@ -253,17 +253,19 @@ register SV **strp;
av = (AV*)NEWSV(8,0);
sv_upgrade((SV *) av,SVt_PVAV);
- New(4,ary,size+1,SV*);
- AvALLOC(av) = ary;
AvFLAGS(av) = AVf_REAL;
- SvPVX(av) = (char*)ary;
- AvFILL(av) = size - 1;
- AvMAX(av) = size - 1;
- for (i = 0; i < size; i++) {
- assert (*strp);
- ary[i] = NEWSV(7,0);
- sv_setsv(ary[i], *strp);
- strp++;
+ if (size) { /* `defined' was returning undef for size==0 anyway. */
+ New(4,ary,size,SV*);
+ AvALLOC(av) = ary;
+ SvPVX(av) = (char*)ary;
+ AvFILL(av) = size - 1;
+ AvMAX(av) = size - 1;
+ for (i = 0; i < size; i++) {
+ assert (*strp);
+ ary[i] = NEWSV(7,0);
+ sv_setsv(ary[i], *strp);
+ strp++;
+ }
}
return av;
}