diff --git a/libsrc/general/array.hpp b/libsrc/general/array.hpp index 5f554dbb..4bf7356e 100644 --- a/libsrc/general/array.hpp +++ b/libsrc/general/array.hpp @@ -78,18 +78,18 @@ namespace netgen { protected: /// the size - int size; + size_t size; /// the data T * data; public: typedef T TELEM; /// provide size and memory - FlatArray (int asize, T * adata) + FlatArray (size_t asize, T * adata) : size(asize), data(adata) { ; } /// the size - int Size() const { return size; } + size_t Size() const { return size; } ArrayIterator begin() const { return ArrayIterator (*this, BASE); } @@ -228,7 +228,7 @@ namespace netgen using FlatArray::data; /// physical size of array - int allocsize; + size_t allocsize; /// memory is responsibility of container bool ownmem; @@ -242,7 +242,7 @@ namespace netgen ownmem = 1; } - explicit Array(int asize) + explicit Array(size_t asize) : FlatArray (asize, new T[asize]) { allocsize = asize; @@ -286,7 +286,7 @@ namespace netgen } /// Change logical size. If necessary, do reallocation. Keeps contents. - void SetSize(int nsize) + void SetSize(size_t nsize) { if (nsize > allocsize) ReSize (nsize); @@ -294,7 +294,7 @@ namespace netgen } /// Change physical size. Keeps logical size. Keeps contents. - void SetAllocSize (int nallocsize) + void SetAllocSize (size_t nallocsize) { if (nallocsize > allocsize) ReSize (nallocsize); @@ -398,16 +398,16 @@ namespace netgen private: /// resize array, at least to size minsize. copy contents - void ReSize (int minsize) + void ReSize (size_t minsize) { - int nsize = 2 * allocsize; + size_t nsize = 2 * allocsize; if (nsize < minsize) nsize = minsize; if (data) { T * p = new T[nsize]; - int mins = (nsize < size) ? nsize : size; + size_t mins = (nsize < size) ? nsize : size; // memcpy (p, data, mins * sizeof(T)); #if defined(__GNUG__) && __GNUC__ < 5 && !defined(__clang__) @@ -448,7 +448,7 @@ namespace netgen // double mem[(S*sizeof(T)+7) / 8]; public: /// Generate array of logical and physical size asize - explicit ArrayMem(int asize = 0) + explicit ArrayMem(size_t asize = 0) : Array (S, static_cast (static_cast(&mem[0]))) { size = asize; @@ -470,7 +470,7 @@ namespace netgen ArrayMem & operator= (const FlatArray & a2) { this->SetSize (a2.Size()); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) (*this)[i] = a2[i]; return *this; } diff --git a/libsrc/general/mystring.cpp b/libsrc/general/mystring.cpp index 279a197b..e0ee1f26 100644 --- a/libsrc/general/mystring.cpp +++ b/libsrc/general/mystring.cpp @@ -114,6 +114,18 @@ MyStr::MyStr(int i) strcpy(str, buffer); } +MyStr::MyStr(unsigned int i) +{ + char buffer[32]; + sprintf(buffer, "%d", i); + length = unsigned(strlen(buffer)); + if (length > SHORTLEN) + str = new char[length + 1]; + else + str = shortstr; + strcpy(str, buffer); +} + MyStr::MyStr(void * p) { char buffer[32]; @@ -139,6 +151,18 @@ MyStr::MyStr(long l) strcpy(str, buffer); } +MyStr::MyStr(unsigned long l) +{ + char buffer[32]; + sprintf(buffer, "%ld", l); + length = unsigned(strlen(buffer)); + if (length > SHORTLEN) + str = new char[length + 1]; + else + str = shortstr; + strcpy(str, buffer); +} + MyStr::MyStr(double d) { char buffer[32]; diff --git a/libsrc/general/mystring.hpp b/libsrc/general/mystring.hpp index 75655362..2b9eab6f 100644 --- a/libsrc/general/mystring.hpp +++ b/libsrc/general/mystring.hpp @@ -50,8 +50,10 @@ public: MyStr(char); MyStr(const MyStr &); MyStr(int); + MyStr(unsigned); MyStr(void *); MyStr(long); + MyStr(unsigned long); MyStr(double); MyStr(const Point3d& p); MyStr(const Vec3d& p);