From d75f4e79ce22c3eca766beb260e7c3654939f35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Fri, 12 Jan 2018 15:55:29 +0100 Subject: [PATCH] 64bit issue in Table allocation --- libsrc/general/table.cpp | 28 ++++++++++++++-------------- libsrc/general/table.hpp | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libsrc/general/table.cpp b/libsrc/general/table.cpp index d9d6cf13..7b7b4444 100644 --- a/libsrc/general/table.cpp +++ b/libsrc/general/table.cpp @@ -30,16 +30,16 @@ namespace netgen BASE_TABLE :: BASE_TABLE (const FlatArray & entrysizes, int elemsize) : data(entrysizes.Size()) { - int i, cnt = 0; - int n = entrysizes.Size(); + size_t cnt = 0; + size_t n = entrysizes.Size(); - for (i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) cnt += entrysizes[i]; oneblock = new char[elemsize * cnt]; // mem_total_alloc_table += elemsize * cnt; cnt = 0; - for (i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { data[i].maxsize = entrysizes[i]; data[i].size = 0; @@ -171,15 +171,15 @@ namespace netgen void BASE_TABLE :: AllocateElementsOneBlock (int elemsize) { - int cnt = 0; - int n = data.Size(); + size_t cnt = 0; + size_t n = data.Size(); - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) cnt += data[i].maxsize; oneblock = new char[elemsize * cnt]; cnt = 0; - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { data[i].size = 0; data[i].col = &oneblock[elemsize * cnt]; @@ -189,18 +189,18 @@ namespace netgen - int BASE_TABLE :: AllocatedElements () const + size_t BASE_TABLE :: AllocatedElements () const { - int els = 0; - for (int i = 0; i < data.Size(); i++) + size_t els = 0; + for (size_t i = 0; i < data.Size(); i++) els += data[i].maxsize; return els; } - int BASE_TABLE :: UsedElements () const + size_t BASE_TABLE :: UsedElements () const { - int els = 0; - for (int i = 0; i < data.Size(); i++) + size_t els = 0; + for (size_t i = 0; i < data.Size(); i++) els += data[i].size; return els; } diff --git a/libsrc/general/table.hpp b/libsrc/general/table.hpp index af6ea49e..857ab8ee 100644 --- a/libsrc/general/table.hpp +++ b/libsrc/general/table.hpp @@ -84,8 +84,8 @@ public: /// void AllocateElementsOneBlock (int elemsize); - int AllocatedElements () const; - int UsedElements () const; + size_t AllocatedElements () const; + size_t UsedElements () const; void SetElementSizesToMaxSizes (); };