On Tue, Jan 24, 2012 at 09:46:16AM +0100, Tanguy LE CARROUR wrote:Yes, as it's a macro usually defined in libc headers.
> 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?
#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