[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN/internal allocator.hh
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN/internal allocator.hh |
Date: |
Wed, 25 Mar 2009 21:14:55 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 09/03/25 21:14:55
Modified files:
internal : allocator.hh
Log message:
Make dynamic matrix throw if it is constructed with 2 negative
dimensions
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/allocator.hh?cvsroot=toon&r1=1.17&r2=1.18
Patches:
Index: allocator.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/allocator.hh,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- allocator.hh 6 Mar 2009 15:34:33 -0000 1.17
+++ allocator.hh 25 Mar 2009 21:14:55 -0000 1.18
@@ -8,6 +8,7 @@
// whether data or a reference to data should be copied.
namespace Internal
{
+
template<int Size, class Precision, bool heap> class StackOrHeap
{
public:
@@ -198,14 +199,14 @@
Precision* const my_data;
MatrixAlloc(const MatrixAlloc& m)
- :my_rows(m.my_rows),my_cols(m.my_cols),my_data(new
Precision[my_rows*my_cols]) {
+ :my_rows(m.my_rows),my_cols(m.my_cols),my_data(new Precision[my_rows>=0
&& my_cols >=0 ?my_rows*my_cols:-1]) {
const int size=my_rows*my_cols;
for(int i=0; i < size; i++)
my_data[i] = m.my_data[i];
}
MatrixAlloc(int r, int c)
- :my_rows(r),my_cols(c),my_data(new Precision[r*c]) {
+ :my_rows(r),my_cols(c),my_data(new Precision[r>=0 && c>=0 ?r*c:-1]) {
}
~MatrixAlloc() {
- [Toon-members] TooN/internal allocator.hh,
Edward Rosten <=