ref: f7f3e4780a5e0733f8699b7722811fb0887af8f1
parent: beb665051bc635299e905ecb8abc5dfd9c3f011e
author: ftrvxmtrx <devnull@localhost>
date: Fri May 2 00:27:29 EDT 2014
bio: Brdstr, Bopen: set malloc tag to the caller
--- a/sys/src/libbio/binit.c
+++ b/sys/src/libbio/binit.c
@@ -114,6 +114,7 @@
if(f < 0)
return 0;
bp = malloc(sizeof(Biobuf));
+ setmalloctag(bp, getcallerpc(&name));
Binits(bp, f, mode, bp->b, sizeof(bp->b));
bp->flag = Bmagic; /* mark bp open & malloced */
return bp;
--- a/sys/src/libbio/brdstr.c
+++ b/sys/src/libbio/brdstr.c
@@ -51,7 +51,8 @@
if(ep) {
j = (ep - ip) + 1;
bp->icount += j;
- return badd(nil, &bp->rdline, ip, j, delim, nulldelim);
+ p = badd(nil, &bp->rdline, ip, j, delim, nulldelim);
+ goto out;
}
/*
@@ -72,7 +73,7 @@
if(j < 0)
Berror(bp, "read error: %r");
if(j <= 0 && i == 0)
- return p;
+ goto out;
if(j <= 0 && i > 0){
/*
* end of file but no delim. pretend we got a delim
@@ -100,7 +101,8 @@
}
j = (ep - (char*)bp->bbuf) + 1;
bp->icount = j - i;
- return badd(p, &bp->rdline, ip, j, delim, nulldelim);
+ p = badd(p, &bp->rdline, ip, j, delim, nulldelim);
+ goto out;
}
ip += j;
}
@@ -113,4 +115,7 @@
bp->icount = 0;
bp->gbuf = bp->ebuf;
}
+out:
+ setmalloctag(p, getcallerpc(&bp));
+ return p;
}