use enumerated size for maxintwidth Reference: /n/atom/patch/applied/fmtsrcsbits Date: Tue Apr 15 20:35:49 CES 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/libc/fmt/dofmt.c Tue Apr 15 20:34:59 2014 +++ /sys/src/libc/fmt/dofmt.c Tue Apr 15 20:34:59 2014 @@ -305,11 +305,16 @@ return _fmtrcpy(f, x, 1); } +enum { + /* %,#llb could emit a sign, "0b" and 64 digits with 21 commas */ + Maxintwidth = 1 + 2 + 64 + 64/3, +}; + /* fmt an integer */ int _ifmt(Fmt *f) { - char buf[88], *p, *conv; + char buf[Maxintwidth + 1], *p, *conv; uvlong vu; ulong u; uintptr pu; --- /sys/src/libc/fmt/vsmprint.c Tue Apr 15 20:34:59 2014 +++ /sys/src/libc/fmt/vsmprint.c Tue Apr 15 20:34:59 2014 @@ -38,6 +38,7 @@ f->start = malloc(n); if(f->start == nil) return -1; + setmalloctag(f->start, getcallerpc(&f)); f->to = f->start; f->stop = (char*)f->start + n - 1; f->flush = fmtStrFlush; @@ -60,11 +61,12 @@ f.args = args; n = dofmt(&f, fmt); if(f.start == nil) - return nil; + return nil; /* realloc failed? */ if(n < 0){ free(f.start); return nil; } + setmalloctag(f.start, getcallerpc(&fmt)); *(char*)f.to = '\0'; return f.start; }