diff options
author | Derick Rethans <derick@php.net> | 2005-07-05 18:30:30 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2005-07-05 18:30:30 +0000 |
commit | d75d455737f8036f5f393f5d6191be19f04f1461 (patch) | |
tree | c3df2069eee06b5a13e0df9f43fc8a8a0ce954e0 | |
parent | 312a8eede3b76a5389832021a7c8483050d9271e (diff) | |
download | php-git-d75d455737f8036f5f393f5d6191be19f04f1461.tar.gz |
- Change memory management so that tzinfo structures can live outside time
structures too.
-rw-r--r-- | ext/date/lib/timelib.c | 4 | ||||
-rw-r--r-- | ext/date/php_date.c | 19 |
2 files changed, 13 insertions, 10 deletions
diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c index 576b2e2efc..eae26aba84 100644 --- a/ext/date/lib/timelib.c +++ b/ext/date/lib/timelib.c @@ -49,10 +49,6 @@ void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr) void timelib_time_dtor(timelib_time* t) { TIMELIB_TIME_FREE(t->tz_abbr); - if (t->tz_info) { - timelib_tzinfo_dtor(t->tz_info); - t->tz_info = NULL; - } TIMELIB_TIME_FREE(t); } diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 9bf2ac9e27..689e05fc92 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -361,6 +361,9 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime) string = php_format_date(format, format_len, t, localtime); RETVAL_STRING(string, 0); + if (localtime) { + timelib_tzinfo_dtor(tzi); + } timelib_time_dtor(t); } /* }}} */ @@ -440,16 +443,16 @@ PHP_FUNCTION(strtotime) ts = timelib_date_to_int(t, &error2); /* if tz_info is not a copy, avoid double free */ - if (now->tz_info == tzi) { - now->tz_info = NULL; + if (now->tz_info != tzi) { + timelib_tzinfo_dtor(now->tz_info); } - if (t->tz_info == tzi) { - t->tz_info = NULL; + if (t->tz_info != tzi) { + timelib_tzinfo_dtor(t->tz_info); } + timelib_tzinfo_dtor(tzi); timelib_time_dtor(now); timelib_time_dtor(t); - timelib_tzinfo_dtor(tzi); if (error1 || error2) { RETURN_FALSE; @@ -535,8 +538,10 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) /* Clean up and return */ ts = timelib_date_to_int(now, &error); ts += adjust_seconds; - timelib_time_dtor(now); + if (!gmt) { + timelib_tzinfo_dtor(tzi); + } if (error) { RETURN_FALSE; @@ -729,6 +734,7 @@ PHP_FUNCTION(localtime) add_next_index_long(return_value, ts->dst); } + timelib_tzinfo_dtor(tzi); timelib_time_dtor(ts); } /* }}} */ @@ -763,6 +769,7 @@ PHP_FUNCTION(getdate) add_assoc_string(return_value, "month", mon_full_names[ts->m - 1], 1); add_index_long(return_value, 0, timestamp); + timelib_tzinfo_dtor(tzi); timelib_time_dtor(ts); } /* }}} */ |