Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
relax assertion in _d_arrayshrinkfit
Browse files Browse the repository at this point in the history
  • Loading branch information
rainers committed Dec 17, 2014
1 parent ac403db commit e25cab1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/rt/lifetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,6 @@ extern(C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) /+nothrow+/
if(info.base && (info.attr & BlkAttr.APPENDABLE))
{
auto newsize = (arr.ptr - __arrayStart(info)) + cursize;
auto oldsize = __arrayAllocLength(info, tinext);
if (newsize > oldsize)
onInvalidMemoryOperationError();

debug(PRINTF) printf("setting allocated size to %d\n", (arr.ptr - info.base) + cursize);

Expand All @@ -660,11 +657,16 @@ extern(C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) /+nothrow+/
{
auto sti = cast(TypeInfo_Struct)cast(void*)tinext;
if (sti.xdtor)
finalize_array(arr.ptr + cursize, oldsize - cursize, sti);
{
auto oldsize = __arrayAllocLength(info, tinext);
if (oldsize > cursize)
finalize_array(arr.ptr + cursize, oldsize - cursize, sti);
}
}
// Note: Since we "assume" the append is safe, it means it is not shared.
// Since it is not shared, we also know it won't throw (no lock).
__setArrayAllocLength(info, newsize, false, tinext);
if (!__setArrayAllocLength(info, newsize, false, tinext))
onInvalidMemoryOperationError();
}
}

Expand Down

0 comments on commit e25cab1

Please sign in to comment.