mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 15:40:36 +03:00
Adds assert messages
This commit is contained in:
parent
ad540ccaa2
commit
ef71418e73
1 changed files with 4 additions and 2 deletions
|
@ -1218,7 +1218,8 @@ private:
|
||||||
import core.checkedint : mulu;
|
import core.checkedint : mulu;
|
||||||
bool overflow;
|
bool overflow;
|
||||||
const rc = mulu(r, c, overflow);
|
const rc = mulu(r, c, overflow);
|
||||||
if (overflow) assert(0);
|
assert(!overflow, "Overflow during multiplication to determine number "
|
||||||
|
~ " of matrix elements");
|
||||||
rows = r;
|
rows = r;
|
||||||
cols = c;
|
cols = c;
|
||||||
if (_matrix.length < rc)
|
if (_matrix.length < rc)
|
||||||
|
@ -1226,7 +1227,8 @@ private:
|
||||||
import core.exception : onOutOfMemoryError;
|
import core.exception : onOutOfMemoryError;
|
||||||
import core.stdc.stdlib : realloc;
|
import core.stdc.stdlib : realloc;
|
||||||
const nbytes = mulu(rc, _matrix[0].sizeof, overflow);
|
const nbytes = mulu(rc, _matrix[0].sizeof, overflow);
|
||||||
if (overflow) assert(0);
|
assert(!overflow, "Overflow during multiplication to determine "
|
||||||
|
~ " number of bytes of matrix");
|
||||||
auto m = cast(CostType *) realloc(_matrix.ptr, nbytes);
|
auto m = cast(CostType *) realloc(_matrix.ptr, nbytes);
|
||||||
if (!m)
|
if (!m)
|
||||||
onOutOfMemoryError();
|
onOutOfMemoryError();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue