Regarding global variables memory allocation and gtime funtion
- From: sunil <sunil.vvn@xxxxxxxxx>
- Date: Wed, 27 Feb 2008 01:30:13 -0800 (PST)
Hi,
Am developing one shared library for one application.
In that .so am having one global array of structure ( two more
different structure pointers in this struct).
Once the application is launched, then I am allocating the memory on
the heap for the internal structures.
To print the log messages I am using the below mentioned global
variables and time header functions.
variables
static time_t ltime;
static char timeString[TIMESTAMP_SIZE];
static struct tm *newtime;
functions
time(<ime);
newtime = gmtime(<ime);
memset(timeString,'\0',TIMESTAMP_SIZE);
strftime(timeString, TIMESTAMP_SIZE,"%Y-%m-%d-%X%z------",newtime);
And am using the above timestring variable to print the timestamp.
It is working fine on unix boxes.
It is failing in some boxes after printing some log messages.
After executing the gmtime function, the values of the internal
structures are becoming null.
And the program is trying to access the null values and it is failing.
If I make the above time related variables to static(earlier the
variables are global) then the program is executing fine without any
problems.
Am unable to get it, why the program is failing in case of global
variables.
Regards
Sunil
.
- Follow-Ups:
- Re: Regarding global variables memory allocation and gtime funtion
- From: Paul Pluzhnikov
- Re: Regarding global variables memory allocation and gtime funtion
- Prev by Date: Re: Benchmarking an IO library
- Next by Date: Is a binary with this libraries portable
- Previous by thread: c++, java, cobol
- Next by thread: Re: Regarding global variables memory allocation and gtime funtion
- Index(es):
Relevant Pages
|