Skip to content

Commit 686df95

Browse files
committed
---
yaml --- r: 113991 b: refs/heads/master c: 0621cca h: refs/heads/master i: 113989: 35fe20e 113987: 0f0a429 113983: 4239aab v: v3
1 parent 224e2c2 commit 686df95

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f8e92cbbe3337974caca28b801efa26734b3c6f9
2+
refs/heads/master: 0621ccac626ef4ca15e2cdf0aceed13ad0d3f848
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/src/libstd/vec.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,11 @@ impl<T> Container for Vec<T> {
403403

404404
// FIXME: #13996: need a way to mark the return value as `noalias`
405405
#[inline(never)]
406-
unsafe fn alloc_or_realloc(ptr: *mut u8, size: uint, align: uint, old_size: uint) -> *mut u8 {
406+
unsafe fn alloc_or_realloc<T>(ptr: *mut T, size: uint, old_size: uint) -> *mut T {
407407
if old_size == 0 {
408-
allocate(size, align)
408+
allocate(size, min_align_of::<T>()) as *mut T
409409
} else {
410-
reallocate(ptr, size, align, old_size)
410+
reallocate(ptr as *mut u8, size, min_align_of::<T>(), old_size) as *mut T
411411
}
412412
}
413413

@@ -491,8 +491,7 @@ impl<T> Vec<T> {
491491
if capacity > self.cap {
492492
let size = capacity.checked_mul(&size_of::<T>()).expect("capacity overflow");
493493
unsafe {
494-
self.ptr = alloc_or_realloc(self.ptr as *mut u8, size, min_align_of::<T>(),
495-
self.cap * size_of::<T>()) as *mut T;
494+
self.ptr = alloc_or_realloc(self.ptr, size, self.cap * size_of::<T>());
496495
}
497496
self.cap = capacity;
498497
}
@@ -573,8 +572,7 @@ impl<T> Vec<T> {
573572
let size = max(old_size, 2 * size_of::<T>()) * 2;
574573
if old_size > size { fail!("capacity overflow") }
575574
unsafe {
576-
self.ptr = alloc_or_realloc(self.ptr as *mut u8, size, min_align_of::<T>(),
577-
self.cap * size_of::<T>()) as *mut u8 as *mut T;
575+
self.ptr = alloc_or_realloc(self.ptr, size, self.cap * size_of::<T>());
578576
}
579577
self.cap = max(self.cap, 2) * 2;
580578
}

0 commit comments

Comments
 (0)