Skip to content

Commit 74b2d9e

Browse files
committed
rt: Remove last use of C++ exchange alloc
1 parent 2c0f9bd commit 74b2d9e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/libextra/time.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ pub struct Tm {
121121
}
122122

123123
pub fn empty_tm() -> Tm {
124+
// 64 is the max size of the timezone buffer allocated on windows
125+
// in rust_localtime. In glibc the max timezone size is supposedly 3.
126+
let zone = str::with_capacity(64);
124127
Tm {
125128
tm_sec: 0_i32,
126129
tm_min: 0_i32,
@@ -132,7 +135,7 @@ pub fn empty_tm() -> Tm {
132135
tm_yday: 0_i32,
133136
tm_isdst: 0_i32,
134137
tm_gmtoff: 0_i32,
135-
tm_zone: ~"",
138+
tm_zone: zone,
136139
tm_nsec: 0_i32,
137140
}
138141
}

src/rt/rust_builtin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void tm_to_rust_tm(tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
292292

293293
if (zone != NULL) {
294294
size_t size = strlen(zone);
295-
reserve_vec_exact(&out_tm->tm_zone, size);
295+
assert(out_tm->tm_zone->alloc >= size);
296296
memcpy(out_tm->tm_zone->data, zone, size);
297297
out_tm->tm_zone->fill = size;
298298
}

0 commit comments

Comments
 (0)