[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: memstat-0.9 hurd patch (PATH_MAX)



2012/1/24 Richard Braun <rbraun@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

Reply to: