Skip to content

Commit

Permalink
Replace 0 with NULL for compact and wchar mode specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
zeux committed Oct 16, 2023
1 parent 60d9656 commit dab3a2f
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/pugixml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ PUGI_IMPL_NS_BEGIN
class compact_hash_table
{
public:
compact_hash_table(): _items(0), _capacity(0), _count(0)
compact_hash_table(): _items(NULL), _capacity(0), _count(0)
{
}

Expand All @@ -313,19 +313,19 @@ PUGI_IMPL_NS_BEGIN
if (_items)
{
xml_memory::deallocate(_items);
_items = 0;
_items = NULL;
_capacity = 0;
_count = 0;
}
}

void* find(const void* key)
{
if (_capacity == 0) return 0;
if (_capacity == 0) return NULL;

item_t* item = get_item(key);
assert(item);
assert(item->key == key || (item->key == 0 && item->value == 0));
assert(item->key == key || (item->key == NULL && item->value == NULL));

return item->value;
}
Expand All @@ -337,7 +337,7 @@ PUGI_IMPL_NS_BEGIN
item_t* item = get_item(key);
assert(item);

if (item->key == 0)
if (item->key == NULL)
{
_count++;
item->key = key;
Expand Down Expand Up @@ -380,15 +380,15 @@ PUGI_IMPL_NS_BEGIN
{
item_t& probe_item = _items[bucket];

if (probe_item.key == key || probe_item.key == 0)
if (probe_item.key == key || probe_item.key == NULL)
return &probe_item;

// hash collision, quadratic probing
bucket = (bucket + probe + 1) & hashmod;
}

assert(false && "Hash table is full"); // unreachable
return 0;
return NULL;
}

static PUGI_IMPL_UNSIGNED_OVERFLOW unsigned int hash(const void* key)
Expand Down Expand Up @@ -483,9 +483,9 @@ PUGI_IMPL_NS_BEGIN
result->freed_size = 0;

#ifdef PUGIXML_COMPACT
result->compact_string_base = 0;
result->compact_shared_parent = 0;
result->compact_page_marker = 0;
result->compact_string_base = NULL;
result->compact_shared_parent = NULL;
result->compact_page_marker = NULL;
#endif

return result;
Expand Down Expand Up @@ -525,7 +525,7 @@ PUGI_IMPL_NS_BEGIN
xml_allocator(xml_memory_page* root): _root(root), _busy_size(root->busy_size)
{
#ifdef PUGIXML_COMPACT
_hash = 0;
_hash = NULL;
#endif
}

Expand Down Expand Up @@ -572,7 +572,7 @@ PUGI_IMPL_NS_BEGIN
void* allocate_object(size_t size, xml_memory_page*& out_page)
{
void* result = allocate_memory(size + sizeof(uint32_t), out_page);
if (!result) return 0;
if (!result) return NULL;

// adjust for marker
ptrdiff_t offset = static_cast<char*>(result) - reinterpret_cast<char*>(out_page->compact_page_marker);
Expand Down Expand Up @@ -628,9 +628,9 @@ PUGI_IMPL_NS_BEGIN

#ifdef PUGIXML_COMPACT
// reset compact state to maximize efficiency
page->compact_string_base = 0;
page->compact_shared_parent = 0;
page->compact_page_marker = 0;
page->compact_string_base = NULL;
page->compact_shared_parent = NULL;
page->compact_page_marker = NULL;
#endif

_busy_size = 0;
Expand Down Expand Up @@ -874,7 +874,7 @@ PUGI_IMPL_NS_BEGIN
return compact_get_value<header_offset, T>(this);
}
else
return 0;
return NULL;
}

T* operator->() const
Expand Down Expand Up @@ -917,7 +917,7 @@ PUGI_IMPL_NS_BEGIN
{
xml_memory_page* page = compact_get_page(this, header_offset);

if (PUGI_IMPL_UNLIKELY(page->compact_shared_parent == 0))
if (PUGI_IMPL_UNLIKELY(page->compact_shared_parent == NULL))
page->compact_shared_parent = value;

if (page->compact_shared_parent == value)
Expand Down Expand Up @@ -954,7 +954,7 @@ PUGI_IMPL_NS_BEGIN
return compact_get_value<header_offset, T>(this);
}
else
return 0;
return NULL;
}

T* operator->() const
Expand Down Expand Up @@ -984,7 +984,7 @@ PUGI_IMPL_NS_BEGIN
{
xml_memory_page* page = compact_get_page(this, header_offset);

if (PUGI_IMPL_UNLIKELY(page->compact_string_base == 0))
if (PUGI_IMPL_UNLIKELY(page->compact_string_base == NULL))
page->compact_string_base = value;

ptrdiff_t offset = value - page->compact_string_base;
Expand Down Expand Up @@ -1050,7 +1050,7 @@ PUGI_IMPL_NS_BEGIN
}
}
else
return 0;
return NULL;
}

private:
Expand Down Expand Up @@ -4639,7 +4639,7 @@ PUGI_IMPL_NS_BEGIN
PUGI_IMPL_FN double get_value_double(const char_t* value)
{
#ifdef PUGIXML_WCHAR_MODE
return wcstod(value, 0);
return wcstod(value, NULL);
#else
return strtod(value, NULL);
#endif
Expand All @@ -4648,7 +4648,7 @@ PUGI_IMPL_NS_BEGIN
PUGI_IMPL_FN float get_value_float(const char_t* value)
{
#ifdef PUGIXML_WCHAR_MODE
return static_cast<float>(wcstod(value, 0));
return static_cast<float>(wcstod(value, NULL));
#else
return static_cast<float>(strtod(value, NULL));
#endif
Expand Down Expand Up @@ -7308,7 +7308,7 @@ namespace pugi
doc->_hash = &doc->hash;

// make sure we don't access other hash up until the end when we reinitialize other document
other->_hash = 0;
other->_hash = NULL;
#endif

// move page structure
Expand Down Expand Up @@ -8616,7 +8616,7 @@ PUGI_IMPL_NS_BEGIN

// parse string
#ifdef PUGIXML_WCHAR_MODE
return wcstod(string, 0);
return wcstod(string, NULL);
#else
return strtod(string, NULL);
#endif
Expand Down

0 comments on commit dab3a2f

Please sign in to comment.