about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-08-22 22:11:30 -0700
committerBrian Anderson <banderson@mozilla.com>2013-08-23 14:46:23 -0700
commit74b2d9e19b2784aed009bd34aaeed43248944aca (patch)
treebd062d8b2a2507e9e3b13abc6f49e9c3b198fc7a
parent2c0f9bd35493def5e23f0f43ddeba54da9d788b4 (diff)
downloadrust-74b2d9e19b2784aed009bd34aaeed43248944aca.tar.gz
rust-74b2d9e19b2784aed009bd34aaeed43248944aca.zip
rt: Remove last use of C++ exchange alloc
-rw-r--r--src/libextra/time.rs5
-rw-r--r--src/rt/rust_builtin.cpp2
2 files changed, 5 insertions, 2 deletions
diff --git a/src/libextra/time.rs b/src/libextra/time.rs
index 257d941e4af..6119170f130 100644
--- a/src/libextra/time.rs
+++ b/src/libextra/time.rs
@@ -121,6 +121,9 @@ pub struct Tm {
 }
 
 pub fn empty_tm() -> Tm {
+    // 64 is the max size of the timezone buffer allocated on windows
+    // in rust_localtime. In glibc the max timezone size is supposedly 3.
+    let zone = str::with_capacity(64);
     Tm {
         tm_sec: 0_i32,
         tm_min: 0_i32,
@@ -132,7 +135,7 @@ pub fn empty_tm() -> Tm {
         tm_yday: 0_i32,
         tm_isdst: 0_i32,
         tm_gmtoff: 0_i32,
-        tm_zone: ~"",
+        tm_zone: zone,
         tm_nsec: 0_i32,
     }
 }
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index de86035b632..d7cb0296a17 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -292,7 +292,7 @@ void tm_to_rust_tm(tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
 
     if (zone != NULL) {
         size_t size = strlen(zone);
-        reserve_vec_exact(&out_tm->tm_zone, size);
+        assert(out_tm->tm_zone->alloc >= size);
         memcpy(out_tm->tm_zone->data, zone, size);
         out_tm->tm_zone->fill = size;
     }