Kaydet (Commit) 8239f0ff authored tarafından Guido van Rossum's avatar Guido van Rossum

fix leaks

üst 62de97f2
...@@ -233,22 +233,35 @@ static struct methodlist time_methods[] = { ...@@ -233,22 +233,35 @@ static struct methodlist time_methods[] = {
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
static void
ins(d, name, v)
object *d;
char *name;
object *v;
{
if (v == NULL)
fatal("Can't initialize time module -- NULL value");
if (dictinsert(d, name, v) != 0)
fatal("Can't initialize time module -- dictinsert failed");
DECREF(v);
}
void void
inittime() inittime()
{ {
object *m, *d; object *m, *d, *v;
m = initmodule("time", time_methods); m = initmodule("time", time_methods);
d = getmoduledict(m); d = getmoduledict(m);
#ifdef HAVE_TZNAME #ifdef HAVE_TZNAME
tzset(); tzset();
dictinsert(d, "timezone", newintobject((long)timezone)); ins(d, "timezone", newintobject((long)timezone));
#ifdef HAVE_ALTZONE #ifdef HAVE_ALTZONE
dictinsert(d, "altzone", newintobject((long)altzone)); ins(d, "altzone", newintobject((long)altzone));
#else #else
dictinsert(d, "altzone", newintobject((long)timezone-3600)); ins(d, "altzone", newintobject((long)timezone-3600));
#endif #endif
dictinsert(d, "daylight", newintobject((long)daylight)); ins(d, "daylight", newintobject((long)daylight));
dictinsert(d, "tzname", mkvalue("(zz)", tzname[0], tzname[1])); ins(d, "tzname", mkvalue("(zz)", tzname[0], tzname[1]));
#else /* !HAVE_TZNAME */ #else /* !HAVE_TZNAME */
#if HAVE_TM_ZONE #if HAVE_TM_ZONE
{ {
...@@ -269,12 +282,10 @@ inittime() ...@@ -269,12 +282,10 @@ inittime()
summerzone = -p->tm_gmtoff; summerzone = -p->tm_gmtoff;
strncpy(summername, p->tm_zone ? p->tm_zone : " ", 9); strncpy(summername, p->tm_zone ? p->tm_zone : " ", 9);
summername[9] = '\0'; summername[9] = '\0';
dictinsert(d, "timezone", newintobject(winterzone)); ins(d, "timezone", newintobject(winterzone));
dictinsert(d, "altzone", newintobject(summerzone)); ins(d, "altzone", newintobject(summerzone));
dictinsert(d, "daylight", ins(d, "daylight", newintobject((long)(winterzone != summerzone)));
newintobject((long)(winterzone != summerzone))); ins(d, "tzname", mkvalue("(zz)", wintername, summername));
dictinsert(d, "tzname",
mkvalue("(zz)", wintername, summername));
} }
#endif /* HAVE_TM_ZONE */ #endif /* HAVE_TM_ZONE */
#endif /* !HAVE_TZNAME */ #endif /* !HAVE_TZNAME */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment