derick Tue Jul 8 18:02:32 2008 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/date php_date.c /php-src/ext/date/lib parse_tz.c tm2unixtime.c Log: - MFH: Memory issues - MFH: // style comments http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.43.2.45.2.59&r2=1.43.2.45.2.60&diff_format=u Index: php-src/ext/date/php_date.c diff -u php-src/ext/date/php_date.c:1.43.2.45.2.59 php-src/ext/date/php_date.c:1.43.2.45.2.60 --- php-src/ext/date/php_date.c:1.43.2.45.2.59 Fri May 2 21:36:00 2008 +++ php-src/ext/date/php_date.c Tue Jul 8 18:02:31 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_date.c,v 1.43.2.45.2.59 2008/05/02 21:36:00 derick Exp $ */ +/* $Id: php_date.c,v 1.43.2.45.2.60 2008/07/08 18:02:31 derick Exp $ */ #include "php.h" #include "php_streams.h" @@ -269,9 +269,9 @@ int initialized; int type; union { - timelib_tzinfo *tz; // TIMELIB_ZONETYPE_ID; - timelib_sll utc_offset; // TIMELIB_ZONETYPE_OFFSET - struct // TIMELIB_ZONETYPE_ABBR + timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID; */ + timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */ + struct /* TIMELIB_ZONETYPE_ABBR */ { timelib_sll utc_offset; char *abbr; @@ -1147,14 +1147,6 @@ timelib_update_ts(t, tzi); 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) { - timelib_tzinfo_dtor(now->tz_info); - } - if (t->tz_info != tzi) { - timelib_tzinfo_dtor(t->tz_info); - } - timelib_time_dtor(now); timelib_time_dtor(t); @@ -1561,7 +1553,7 @@ new_obj->time->tz_abbr = strdup(old_obj->time->tz_abbr); } if (old_obj->time->tz_info) { - new_obj->time->tz_info = timelib_tzinfo_clone(old_obj->time->tz_info); + new_obj->time->tz_info = old_obj->time->tz_info; } return new_ov; @@ -1645,9 +1637,6 @@ php_date_obj *intern = (php_date_obj *)object; if (intern->time) { - if (intern->time->tz_info) { - timelib_tzinfo_dtor(intern->time->tz_info); - } timelib_time_dtor(intern->time); } @@ -1685,14 +1674,11 @@ timelib_time *now; timelib_tzinfo *tzi; timelib_error_container *err = NULL; - int free_tzi = 0, type = TIMELIB_ZONETYPE_ID, new_dst, errors_found = 0; + int type = TIMELIB_ZONETYPE_ID, new_dst, errors_found = 0; char *new_abbr; timelib_sll new_offset; if (dateobj->time) { - if (dateobj->time->tz_info) { - timelib_tzinfo_dtor(dateobj->time->tz_info); - } timelib_time_dtor(dateobj->time); } dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB); @@ -1716,8 +1702,7 @@ tzobj = (php_timezone_obj *) zend_object_store_get_object(timezone_object TSRMLS_CC); switch (tzobj->type) { case TIMELIB_ZONETYPE_ID: - tzi = timelib_tzinfo_clone(tzobj->tzi.tz); - free_tzi = 1; + tzi = tzobj->tzi.tz; break; case TIMELIB_ZONETYPE_OFFSET: new_offset = tzobj->tzi.utc_offset; @@ -1730,8 +1715,7 @@ } type = tzobj->type; } else if (dateobj->time->tz_info) { - tzi = timelib_tzinfo_clone(dateobj->time->tz_info); - free_tzi = 1; + tzi = dateobj->time->tz_info; } else { tzi = get_timezone_info(TSRMLS_C); } @@ -1758,12 +1742,6 @@ dateobj->time->have_weekday_relative = dateobj->time->have_relative = 0; - if (type == TIMELIB_ZONETYPE_ID && now->tz_info != tzi) { - timelib_tzinfo_dtor(now->tz_info); - } - if (free_tzi) { - timelib_tzinfo_dtor(tzi); - } timelib_time_dtor(now); return 1; @@ -2016,10 +1994,7 @@ if (tzobj->type != TIMELIB_ZONETYPE_ID) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can only do this for zones with ID for now"); } - if (dateobj->time->tz_info) { - timelib_tzinfo_dtor(dateobj->time->tz_info); - } - timelib_set_timezone(dateobj->time, timelib_tzinfo_clone(tzobj->tzi.tz)); + timelib_set_timezone(dateobj->time, tzobj->tzi.tz); timelib_unixtime2local(dateobj->time, dateobj->time->sse); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_tz.c?r1=1.20.2.6.2.14&r2=1.20.2.6.2.15&diff_format=u Index: php-src/ext/date/lib/parse_tz.c diff -u php-src/ext/date/lib/parse_tz.c:1.20.2.6.2.14 php-src/ext/date/lib/parse_tz.c:1.20.2.6.2.15 --- php-src/ext/date/lib/parse_tz.c:1.20.2.6.2.14 Mon Dec 31 07:20:05 2007 +++ php-src/ext/date/lib/parse_tz.c Tue Jul 8 18:02:32 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: parse_tz.c,v 1.20.2.6.2.14 2007/12/31 07:20:05 sebastian Exp $ */ +/* $Id: parse_tz.c,v 1.20.2.6.2.15 2008/07/08 18:02:32 derick Exp $ */ #include "timelib.h" @@ -391,7 +391,7 @@ switch (t->zone_type) { case TIMELIB_ZONETYPE_ABBR: case TIMELIB_ZONETYPE_OFFSET: - return t->z * 60; + return (t->z + t->dst) * 60; case TIMELIB_ZONETYPE_ID: gmt_offset = timelib_get_time_zone_info(t->sse, t->tz_info); http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/tm2unixtime.c?r1=1.13.2.3.2.4&r2=1.13.2.3.2.5&diff_format=u Index: php-src/ext/date/lib/tm2unixtime.c diff -u php-src/ext/date/lib/tm2unixtime.c:1.13.2.3.2.4 php-src/ext/date/lib/tm2unixtime.c:1.13.2.3.2.5 --- php-src/ext/date/lib/tm2unixtime.c:1.13.2.3.2.4 Sat Jan 26 16:26:47 2008 +++ php-src/ext/date/lib/tm2unixtime.c Tue Jul 8 18:02:32 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tm2unixtime.c,v 1.13.2.3.2.4 2008/01/26 16:26:47 derick Exp $ */ +/* $Id: tm2unixtime.c,v 1.13.2.3.2.5 2008/07/08 18:02:32 derick Exp $ */ #include "timelib.h" @@ -186,10 +186,10 @@ timelib_sll res = 0; timelib_sll eras; - eras = (year - 1970) / 400; + eras = (year - 1970) / 40000; if (eras != 0) { - year = year - (eras * 400); - res += (SECS_PER_ERA * eras); + year = year - (eras * 40000); + res += (SECS_PER_ERA * eras * 100); } if (year >= 1970) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php