2012/1/24 Richard Braun <rbr...@sceen.net> > On Tue, Jan 24, 2012 at 09:46:16AM +0100, Tanguy LE CARROUR wrote: > > I hope I've fixed all the bugs in my patch, but I have one last small > > question: Do I really need to check if BUFSIZ is defined? > > Yes, as it's a macro usually defined in libc headers. > "Usually"?!
> #define FORMAT "/proc/%d/maps" > #define BUFF_SIZE (sizeof(FORMAT) + (sizeof(int) * 3)) /* sizeof() already > includes the terminating \0 */ > > buff = malloc(BUFF_SIZE); > > if (buff == NULL) > handle_error(); > > sprintf(buff, FORMAT, pid); > > #undef FORMAT > #undef BUFF_SIZE > Looks better, thanks. Tanguy