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.

As for this part :

+       buff_size = 11; /* size of the format string without "%x" expressions */
+       buff_size += sizeof(int) * 3 + 1;
+       buff_size += 1; // '\0'
+       buff = (char *)malloc((buff_size) * sizeof(char));
        sprintf(buff, "/proc/%d/maps", pid);

You could do :

#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

-- 
Richard Braun


-- 
To UNSUBSCRIBE, email to debian-hurd-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20120124093926.ga2...@mail.sceen.net

Reply via email to