localtime_r segfaults, localtime doesn't... same values passed to each function...
Christopher Faylor
cgf-no-personal-reply-please@cygwin.com
Sun Jul 10 22:38:00 GMT 2005
On Sun, Jul 10, 2005 at 05:06:12PM -0400, Brian Bisaillon wrote:
>This works...
>
>struct tm *sci_localtime (time_t timep) {
> struct tm *result;
> if ((result = localtime(&timep)) == NULL) {
> int errsv = errno;
> fprintf (stderr, "\nError Code %i: %s at line
>%i of %s function in %s \
> \n", strerror (errsv), 2,
>"sci_localtime_r", "sci_time.c");
> exit (EXIT_FAILURE);
> } else {
> return (result);
> }
>}
>
>This doesn't...
>
>struct tm *sci_localtime_r (time_t timep) {
> struct tm *result;
> if ((localtime_r(&timep, result)) == NULL) {
^^^^^^
You're passing an uninitialized pointer as the second argument to
localtime_r. This is supposed to be the address of a user-defined
struct.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list