Skip to content

Commit e14fd06

Browse files
committed
ext/intl: c++ memory management application to timezone class internals.
1 parent dd3a098 commit e14fd06

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ext/intl/timezone/timezone_class.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
133133
const char *func)
134134
{
135135
zval local_zv_tz;
136-
TimeZone *timeZone;
136+
std::unique_ptr<TimeZone> timeZone;
137137

138138
if (zv_timezone == NULL || Z_TYPE_P(zv_timezone) == IS_NULL) {
139139
timelib_tzinfo *tzinfo = get_timezone_info();
@@ -153,7 +153,7 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
153153
zval_ptr_dtor_str(&local_zv_tz);
154154
return NULL;
155155
}
156-
timeZone = to->utimezone->clone();
156+
timeZone = std::unique_ptr<TimeZone>(to->utimezone->clone());
157157
if (UNEXPECTED(timeZone == NULL)) {
158158
zend_throw_error(IntlException_ce_ptr, "%s: could not clone TimeZone", func);
159159
zval_ptr_dtor_str(&local_zv_tz);
@@ -181,7 +181,7 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
181181
zval_ptr_dtor_str(&local_zv_tz);
182182
return NULL;
183183
}
184-
timeZone = TimeZone::createTimeZone(id);
184+
timeZone = std::unique_ptr<TimeZone>(TimeZone::createTimeZone(id));
185185
if (UNEXPECTED(timeZone == NULL)) {
186186
zend_throw_error(IntlException_ce_ptr, "%s: Could not create time zone", func);
187187
zval_ptr_dtor_str(&local_zv_tz);
@@ -191,14 +191,14 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
191191
zend_throw_error(IntlException_ce_ptr, "%s: No such time zone: '%s'",
192192
func, Z_STRVAL_P(zv_timezone));
193193
zval_ptr_dtor_str(&local_zv_tz);
194-
delete timeZone;
195194
return NULL;
196195
}
197196
}
198197

199198
zval_ptr_dtor_str(&local_zv_tz);
200199

201-
return timeZone;
200+
// well, this is included by the centralized C intl part so the "smart" part can't go further
201+
return timeZone.release();
202202
}
203203
/* }}} */
204204

ext/intl/timezone/timezone_class.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ typedef struct {
3636
intl_error err;
3737

3838
// ICU TimeZone
39+
// TODO?: a direct change isn't possible due to C inclusion (also it s a const)
40+
// but see later it can be made possible through different ICU class usages
3941
const TimeZone *utimezone;
4042

4143
//whether to delete the timezone on object free

0 commit comments

Comments
 (0)