浏览代码

Merge pull request #9776 from ghalliday/issue17316

HPCC-17316 Fix various windows build issues

Reviewed-By: Jake Smith <jake.smith@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 年之前
父节点
当前提交
7b35010742
共有 3 个文件被更改,包括 19 次插入35 次删除
  1. 18 12
      system/jlib/jptree.cpp
  2. 0 22
      system/jlib/jptree.ipp
  3. 1 1
      system/jlib/jutil.cpp

+ 18 - 12
system/jlib/jptree.cpp

@@ -69,26 +69,32 @@ IPropertyTreeIterator *createNullPTreeIterator() { return LINK(nullPTreeIterator
 
 
 //===================================================================
-AtomRefTable *CAtomPTree::keyTable = nullptr;
-AtomRefTable *CAtomPTree::keyTableNC = nullptr;
-CriticalSection CAtomPTree::hashcrit;
-CAttrValHashTable *CAtomPTree::attrHT = nullptr;
-AttrValue **CAtomPTree::freelist = nullptr;
-unsigned CAtomPTree::freelistmax = 0;
-CLargeMemoryAllocator CAtomPTree::freeallocator((memsize_t)-1, 0x1000*sizeof(AttrValue), true);
 
+static AtomRefTable *keyTable = nullptr;
+static AtomRefTable *keyTableNC = nullptr;
+static CriticalSection hashcrit;
+static CAttrValHashTable *attrHT = nullptr;
+static AttrValue **freelist = nullptr;
+static unsigned freelistmax = 0;
+static CLargeMemoryAllocator freeallocator((memsize_t)-1, 0x1000*sizeof(AttrValue), true);
 
 MODULE_INIT(INIT_PRIORITY_JPTREE)
 {
     nullPTreeIterator = new NullPTreeIterator;
-    CAtomPTree::init();
+	keyTable = new AtomRefTable;
+	keyTableNC = new AtomRefTable(true);
+	attrHT = new CAttrValHashTable;
     return true;
 }
 
 MODULE_EXIT()
 {
     nullPTreeIterator->Release();
-    CAtomPTree::kill();
+	delete attrHT;
+	keyTable->Release();
+	keyTableNC->Release();
+	free(freelist);
+	freelist = NULL;
 }
 
 
@@ -3600,7 +3606,9 @@ IPropertyTree *ensurePTree(IPropertyTree *root, const char *xpath)
 
 IPTreeReadException *createPTreeReadException(int code, const char *msg, const char *context, unsigned line, offset_t offset)
 {
-    class jlib_thrown_decl CPTreeReadException : implements IPTreeReadException, public CInterface
+    //Do not use jlib_thrown_decl because it causes problems with VS2017 - I think because of beforeDispose() in CInterfaceOf.
+    //The type of the object actually thrown is IPTreeReadException  which does have a jlib_thrown_decl - so it will still be caught.
+    class CPTreeReadException : implements CInterfaceOf<IPTreeReadException>
     {
         int code;
         StringAttr msg;
@@ -3620,8 +3628,6 @@ IPTreeReadException *createPTreeReadException(int code, const char *msg, const c
             return out;
         }
     public:
-        IMPLEMENT_IINTERFACE;
-
         CPTreeReadException(int _code, const char *_msg, const char *_context, unsigned _line, offset_t _offset) : code(_code), msg(_msg), context(_context), line(_line), offset(_offset) { }
 
         // IException

+ 0 - 22
system/jlib/jptree.ipp

@@ -471,13 +471,6 @@ public:
 
 class jlib_decl CAtomPTree : public PTree
 {
-    static AtomRefTable *keyTable, *keyTableNC;
-    static CriticalSection hashcrit;
-    static CAttrValHashTable *attrHT;
-    static AttrValue **freelist; // entry 0 not used
-    static unsigned freelistmax;
-    static CLargeMemoryAllocator freeallocator;
-
     AttrValue *newAttrArray(unsigned n);
     void freeAttrArray(AttrValue *a, unsigned n);
 
@@ -485,21 +478,6 @@ protected:
     virtual void setAttribute(const char *attr, const char *val) override;
     virtual bool removeAttribute(const char *k) override;
 public:
-    static inline void init()
-    {
-        keyTable = new AtomRefTable;
-        keyTableNC = new AtomRefTable(true);
-        attrHT = new CAttrValHashTable;
-    }
-    static inline void kill()
-    {
-        delete attrHT;
-        keyTable->Release();
-        keyTableNC->Release();
-        free(freelist);
-        freelist = NULL;
-    }
-
     CAtomPTree(const char *name=nullptr, byte flags=ipt_none, IPTArrayValue *value=nullptr, ChildMap *children=nullptr);
     ~CAtomPTree();
     virtual void setName(const char *_name) override;

+ 1 - 1
system/jlib/jutil.cpp

@@ -46,8 +46,8 @@
 #include <signal.h>
 #include <paths.h>
 #include <cmath>
-#include "build-config.h"
 #endif
+#include "build-config.h"
 
 #include "portlist.h"