]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Improve support for clang compilers
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 6 Aug 2012 15:38:12 +0000 (17:38 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 6 Aug 2012 15:38:12 +0000 (17:38 +0200)
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

src/ipc/Queue.cc
src/ipc/Queue.h
src/ipc/StoreMap.cc
src/ipc/StoreMap.h
src/ipc/mem/PageStack.cc
src/ipc/mem/PageStack.h

index c2dceb873526dafebd27c0055d5b4f72b4245bf0..9ce1b94e83bd2bf62d84387a0f08046ae315f9f3 100644 (file)
@@ -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
index ff46a6c1e6640a03896a2f962660aaec96fd0871..45fb3af576b42c369e546c0db2ea0e5a35ca1af0 100644 (file)
@@ -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
 };
 
 /**
index df5cc8c3d376738ffde2e390db2ade0e3ab00386..86bc94156559361c6da032dee8624e6e00298d33 100644 (file)
@@ -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
index c7a2e81f88db2b71c48ec4bea4693290c3f1fa13..7006b39cb14cb3cbc750caaf6f8d80f09fa263f7 100644 (file)
@@ -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:
index 239d598dec634bb6595d2f3fc998e0d39724d3ae..25d84975078c01e916a531cfbaef57903fa494ef 100644 (file)
@@ -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;
 }
 
 /*
index 1eb27e30f62a0e2ba053a149813193f394d87534..85aea0901d4d781272d06df6968c72cd50298da0 100644 (file)
@@ -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<Offset> theFirstWritable;
 
     typedef Atomic::WordT<Value> Item;
-    Item theItems[]; ///< page number storage
+    Item *theItems; ///< page number storage
 };
 
 } // namespace Mem