From f2509e0395cd4e0f655eea77e3da2fab06eb4032 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sun, 29 Aug 2010 15:28:59 +0000 Subject: XPath: memory_block is now POD (no more offsetof warnings) git-svn-id: http://pugixml.googlecode.com/svn/trunk@666 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixpath.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/pugixpath.cpp b/src/pugixpath.cpp index 248e9a4..1bb2d70 100644 --- a/src/pugixpath.cpp +++ b/src/pugixpath.cpp @@ -43,8 +43,9 @@ typedef __int32 int32_t; #if defined(_MSC_VER) # pragma warning(disable: 4127) // conditional expression is constant -# pragma warning(disable: 4611) // interaction between '_setjmp' and C++ object destruction is non-portable # pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +# pragma warning(disable: 4611) // interaction between '_setjmp' and C++ object destruction is non-portable +# pragma warning(disable: 4702) // unreachable code # pragma warning(disable: 4996) // this function or variable may be unsafe #endif @@ -965,17 +966,14 @@ namespace pugi { struct memory_block { - memory_block(): next(0), size(0) - { - } - memory_block* next; - size_t size; char data[xpath_memory_block_size]; }; memory_block* _root; + size_t _root_size; + memory_block _first; public: @@ -1007,8 +1005,11 @@ namespace pugi get_memory_deallocation_function()(alloc); } - xpath_allocator(): _root(&_first) + xpath_allocator() { + _root = &_first; + _root_size = 0; + _first.next = 0; } void* allocate(size_t size) @@ -1016,10 +1017,10 @@ namespace pugi // align size so that we're able to store pointers in subsequent blocks size = (size + sizeof(void*) - 1) & ~(sizeof(void*) - 1); - if (_root->size + size <= xpath_memory_block_size) + if (_root_size + size <= xpath_memory_block_size) { - void* buf = _root->data + _root->size; - _root->size += size; + void* buf = _root->data + _root_size; + _root_size += size; return buf; } else @@ -1031,9 +1032,9 @@ namespace pugi if (!block) return 0; block->next = _root; - block->size = size; _root = block; + _root_size = size; return block->data; } -- cgit v1.2.3