cvs: php-src /ext/date php_date.c /ext/date/lib timelib.c

From: Date: Tue, 05 Jul 2005 18:30:30 +0000
Subject: cvs: php-src /ext/date php_date.c /ext/date/lib timelib.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-32693@lists.php.net to get a copy of this message
derick Tue Jul 5 14:30:30 2005 EDT Modified files: /php-src/ext/date php_date.c /php-src/ext/date/lib timelib.c Log: - Change memory management so that tzinfo structures can live outside time structures too. http://cvs.php.net/diff.php/php-src/ext/date/php_date.c?r1=1.34&r2=1.35&ty=u Index: php-src/ext/date/php_date.c diff -u php-src/ext/date/php_date.c:1.34 php-src/ext/date/php_date.c:1.35 --- php-src/ext/date/php_date.c:1.34 Mon Jul 4 17:27:25 2005 +++ php-src/ext/date/php_date.c Tue Jul 5 14:30:28 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_date.c,v 1.34 2005/07/04 21:27:25 derick Exp $ */ +/* $Id: php_date.c,v 1.35 2005/07/05 18:30:28 derick Exp $ */ #include "php.h" #include "php_streams.h" @@ -361,6 +361,9 @@ 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 @@ 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 @@ /* 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 @@ add_next_index_long(return_value, ts->dst); } + timelib_tzinfo_dtor(tzi); timelib_time_dtor(ts); } /* }}} */ @@ -763,6 +769,7 @@ 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); } /* }}} */ http://cvs.php.net/diff.php/php-src/ext/date/lib/timelib.c?r1=1.5&r2=1.6&ty=u Index: php-src/ext/date/lib/timelib.c diff -u php-src/ext/date/lib/timelib.c:1.5 php-src/ext/date/lib/timelib.c:1.6 --- php-src/ext/date/lib/timelib.c:1.5 Wed Jun 29 15:08:26 2005 +++ php-src/ext/date/lib/timelib.c Tue Jul 5 14:30:30 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: timelib.c,v 1.5 2005/06/29 19:08:26 derick Exp $ */ +/* $Id: timelib.c,v 1.6 2005/07/05 18:30:30 derick Exp $ */ #include "timelib.h" #include <ctype.h> @@ -49,10 +49,6 @@ 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); }

« previous php.cvs (#32693) next »