aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dc.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2008-12-06 15:35:55 -0800
committerRuss Cox <rsc@swtch.com>2008-12-06 15:35:55 -0800
commitab937b56dec51e002ef2e248a3bf9b183f848cc2 (patch)
tree3aaf9022325c1a70442c1334ac220eb58bb91e26 /src/cmd/dc.c
parenteb1392208cead07e9e413b5ad4dbd82069d87c30 (diff)
downloadplan9port-ab937b56dec51e002ef2e248a3bf9b183f848cc2.tar.gz
plan9port-ab937b56dec51e002ef2e248a3bf9b183f848cc2.tar.bz2
plan9port-ab937b56dec51e002ef2e248a3bf9b183f848cc2.zip
dc: clean up minor memory errors
Diffstat (limited to 'src/cmd/dc.c')
-rw-r--r--src/cmd/dc.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/cmd/dc.c b/src/cmd/dc.c
index bdcfadee..fa7f09bc 100644
--- a/src/cmd/dc.c
+++ b/src/cmd/dc.c
@@ -2103,14 +2103,13 @@ copy(Blk *hptr, int size)
if(size > maxsize)
maxsize = size;
sz = length(hptr);
- ptr = nalloc(hptr->beg, size);
+ ptr = malloc(size);
if(ptr == 0) {
- garbage("copy");
- if((ptr = nalloc(hptr->beg, size)) == 0) {
- Bprint(&bout,"copy size %d\n",size);
- ospace("copy");
- }
+ Bprint(&bout,"copy size %d\n",size);
+ ospace("copy");
}
+ memmove(ptr, hptr->beg, sz);
+ memset(ptr+sz, 0, size-sz);
if((hdr = hfree) == 0)
hdr = morehd();
hfree = (Blk *)hdr->rd;