Merge from default. Hope I did it right...
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
#define ARRAY2D_VERBOSE 8
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
template<typename T>
|
||||
class array2D {
|
||||
@@ -98,7 +99,7 @@ public:
|
||||
// use as empty declaration, resize before use!
|
||||
// very useful as a member object
|
||||
array2D() :
|
||||
x(0), y(0), owner(0), data(NULL), ptr(NULL), lock(0) {
|
||||
x(0), y(0), owner(0), ptr(NULL), data(NULL), lock(0) {
|
||||
//printf("got empty array2D init\n");
|
||||
}
|
||||
|
||||
@@ -155,8 +156,8 @@ public:
|
||||
}
|
||||
|
||||
// use with indices
|
||||
T * operator[](size_t index) {
|
||||
assert(index>=0 && index<y);
|
||||
T * operator[](int index) {
|
||||
assert((index>=0) && (index < y));
|
||||
return ptr[index];
|
||||
}
|
||||
|
||||
@@ -251,7 +252,7 @@ private:
|
||||
|
||||
public:
|
||||
multi_array2D(int x, int y, int flags = 0) {
|
||||
for (int i = 0; i < num; i++)
|
||||
for (size_t i = 0; i < num; i++)
|
||||
list[i](x, y, flags);
|
||||
}
|
||||
|
||||
@@ -259,9 +260,9 @@ public:
|
||||
//printf("trying to delete the list of array2D objects\n");
|
||||
}
|
||||
|
||||
array2D<T> & operator[](size_t index) {
|
||||
if (index < 0 || index >= num) {
|
||||
printf("index %zu is out of range[0..%zu]", index, num - 1);
|
||||
array2D<T> & operator[](int index) {
|
||||
if (static_cast<size_t>(index) >= num) {
|
||||
printf("index %0u is out of range[0..%0u]", index, num - 1);
|
||||
raise( SIGSEGV);
|
||||
}
|
||||
return list[index];
|
||||
|
Reference in New Issue
Block a user