[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getline() bug
From: |
Paul Pluzhnikov |
Subject: |
Re: getline() bug |
Date: |
Wed, 25 Jul 2007 13:36:53 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
"John V. Shahid" <jvshahid@gmail.com> writes:
> I think I found a bug in getline().
Nope. The bug is in your program (but I'll grant you -- it's an
obscure one).
Compile your code with -Wall, and you'll see this:
$ gcc -Wall junk3.c
junk3.c: In function 'main':
junk3.c:19: warning: implicit declaration of function 'getline'
junk3.c:7: warning: unused variable 'count'
The 'man getline' tells you to do this:
#define _GNU_SOURCE
Adding that to junk3.c, and compiling again with -Wall, tells you
the root of the problem:
junk3.c: In function 'main':
junk3.c:20: warning: passing argument 2 of 'getline' from incompatible pointer
type
Fixing that problem:
// int lineSize, count;
size_t lineSize;
cures the warning, cures your bug, and makes valgrind happy:
==28863== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
- getline() bug, John V. Shahid, 2007/07/25
- Re: getline() bug,
Paul Pluzhnikov <=