/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "ParserArena.h"
#include "Nodes.h"
+#include <wtf/PassOwnPtr.h>
namespace JSC {
ParserArena::ParserArena()
: m_freeableMemory(0)
, m_freeablePoolEnd(0)
- , m_identifierArena(new IdentifierArena)
{
}
inline void ParserArena::deallocateObjects()
{
+ size_t size = m_deletableObjects.size();
+ for (size_t i = 0; i < size; ++i)
+ m_deletableObjects[i]->~ParserArenaDeletable();
+
if (m_freeablePoolEnd)
fastFree(freeablePool());
- size_t size = m_freeablePools.size();
+ size = m_freeablePools.size();
for (size_t i = 0; i < size; ++i)
fastFree(m_freeablePools[i]);
-
- size = m_deletableObjects.size();
- for (size_t i = 0; i < size; ++i) {
- ParserArenaDeletable* object = m_deletableObjects[i];
- object->~ParserArenaDeletable();
- fastFree(object);
- }
}
ParserArena::~ParserArena()
m_freeableMemory = 0;
m_freeablePoolEnd = 0;
- m_identifierArena->clear();
+ if (m_identifierArena)
+ m_identifierArena->clear();
m_freeablePools.clear();
m_deletableObjects.clear();
m_refCountedObjects.clear();
bool ParserArena::isEmpty() const
{
return !m_freeablePoolEnd
- && m_identifierArena->isEmpty()
+ && (!m_identifierArena || m_identifierArena->isEmpty())
&& m_freeablePools.isEmpty()
&& m_deletableObjects.isEmpty()
&& m_refCountedObjects.isEmpty();