From: Francesco Chemolli Date: Mon, 6 Aug 2012 15:38:12 +0000 (+0200) Subject: Improve support for clang compilers X-Git-Tag: sourceformat-review-1~137 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2cde03031ecb472b30c5bdd9f3355331d6737f5e;p=thirdparty%2Fsquid.git Improve support for clang compilers clang++ doesn't support c++ variable arrays for non-pod types. Change variable arrays to dynamically-allocated arrays, Ipc::QueueReaders, Ipc::StoreMap and Ipc::Mem::PageStack --- diff --git a/src/ipc/Queue.cc b/src/ipc/Queue.cc index c2dceb8735..9ce1b94e83 100644 --- a/src/ipc/Queue.cc +++ b/src/ipc/Queue.cc @@ -51,7 +51,12 @@ Ipc::QueueReader::QueueReader(): popBlocked(1), popSignal(0), Ipc::QueueReaders::QueueReaders(const int aCapacity): theCapacity(aCapacity) { Must(theCapacity > 0); - new (theReaders) QueueReader[theCapacity]; + theReaders=new QueueReader[theCapacity]; +} + +Ipc::QueueReaders::~QueueReaders() +{ + delete[] theReaders; } size_t diff --git a/src/ipc/Queue.h b/src/ipc/Queue.h index ff46a6c1e6..45fb3af576 100644 --- a/src/ipc/Queue.h +++ b/src/ipc/Queue.h @@ -64,11 +64,16 @@ class QueueReaders { public: QueueReaders(const int aCapacity); + ~QueueReaders(); size_t sharedMemorySize() const; static size_t SharedMemorySize(const int capacity); const int theCapacity; /// number of readers - QueueReader theReaders[]; /// readers + QueueReader *theReaders; /// readers +private: + QueueReaders(); //not implemented + QueueReaders& operator =(const QueueReaders&); //not implemented + QueueReaders(const QueueReaders&); //not implemented }; /** diff --git a/src/ipc/StoreMap.cc b/src/ipc/StoreMap.cc index df5cc8c3d3..86bc941565 100644 --- a/src/ipc/StoreMap.cc +++ b/src/ipc/StoreMap.cc @@ -308,6 +308,12 @@ Ipc::StoreMapSlot::set(const StoreEntry &from) Ipc::StoreMap::Shared::Shared(const int aLimit, const size_t anExtrasSize): limit(aLimit), extrasSize(anExtrasSize), count(0) { + slots=new Slot[limit]; +} + +Ipc::StoreMap::Shared::~Shared() +{ + delete[] slots; } size_t diff --git a/src/ipc/StoreMap.h b/src/ipc/StoreMap.h index c7a2e81f88..7006b39cb1 100644 --- a/src/ipc/StoreMap.h +++ b/src/ipc/StoreMap.h @@ -62,11 +62,16 @@ public: Shared(const int aLimit, const size_t anExtrasSize); size_t sharedMemorySize() const; static size_t SharedMemorySize(const int limit, const size_t anExtrasSize); + ~Shared(); const int limit; ///< maximum number of map slots const size_t extrasSize; ///< size of slot extra data Atomic::Word count; ///< current number of map slots - Slot slots[]; ///< slots storage + Slot *slots; ///< slots storage + private: + Shared(); //disabled + Shared &operator=(const Shared&); //disabled + Shared(const Shared&); //disabled }; public: diff --git a/src/ipc/mem/PageStack.cc b/src/ipc/mem/PageStack.cc index 239d598dec..25d8497507 100644 --- a/src/ipc/mem/PageStack.cc +++ b/src/ipc/mem/PageStack.cc @@ -23,6 +23,12 @@ Ipc::Mem::PageStack::PageStack(const uint32_t aPoolId, const unsigned int aCapac // initially, all pages are free for (Offset i = 0; i < theSize; ++i) theItems[i] = i + 1; // skip page number zero to keep numbers positive + theItems=new Item[theSize]; +} + +Ipc::Mem::PageStack::~PageStack() +{ + delete[] theItems; } /* diff --git a/src/ipc/mem/PageStack.h b/src/ipc/mem/PageStack.h index 1eb27e30f6..85aea0901d 100644 --- a/src/ipc/mem/PageStack.h +++ b/src/ipc/mem/PageStack.h @@ -25,6 +25,7 @@ public: typedef uint32_t Value; ///< stack item type (a free page number) PageStack(const uint32_t aPoolId, const unsigned int aCapacity, const size_t aPageSize); + ~PageStack(); unsigned int capacity() const { return theCapacity; } size_t pageSize() const { return thePageSize; } @@ -67,7 +68,7 @@ private: Atomic::WordT theFirstWritable; typedef Atomic::WordT Item; - Item theItems[]; ///< page number storage + Item *theItems; ///< page number storage }; } // namespace Mem