<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -15,7 +15,6 @@
 typedef struct
 {
 	PDB *pdb;
-	Pool *pool;
 	
 	struct evhttp *httpd;
 	struct evhttp_request *request;</diff>
      <filename>source/VertexServer.h</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,12 @@
 #include &lt;stdlib.h&gt;
 #include &lt;stdio.h&gt;
 #include &lt;string.h&gt;
+#include &quot;Pool.h&quot;
+
+Datum *Datum_poolNew(void)
+{
+	return GLOBAL_POOL_ALLOC(Datum)
+}
 
 Datum *Datum_new(void)
 {</diff>
      <filename>source/pdb/Datum.c</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,8 @@ typedef struct
 
 #define DATUM_STACKALLOCATED(name, string) Datum _##name; Datum *name = &amp;_##name; name-&gt;data = (char *)string; name-&gt;size = strlen(string);
 
+Datum *Datum_poolNew(void);
+
 Datum *Datum_new(void);
 Datum *Datum_newWithCString_(const char *s);
 Datum *Datum_clone(Datum *d);</diff>
      <filename>source/pdb/Datum.h</filename>
    </modified>
    <modified>
      <diff>@@ -70,7 +70,6 @@ PDB *PDB_new(void)
 	self-&gt;corruptFile = File_new();
 	self-&gt;unusedPid = Datum_new();
 	self-&gt;useBackups = 1;
-	self-&gt;pool = Pool_new();
 	
 	srand(time(NULL)); // need to do because Datum_makePid64 uses rand 
 	
@@ -83,9 +82,7 @@ void PDB_setYajl_(PDB *self, yajl_gen y)
 }
 
 void PDB_free(PDB *self)
-{
-	PDB_freeNodes(self);
-	
+{	
 	PDB_close(self);
 	File_free(self-&gt;dbFile);
 	File_free(self-&gt;isOpenFile);
@@ -93,7 +90,6 @@ void PDB_free(PDB *self)
 	File_free(self-&gt;newBackupFile);
 	File_free(self-&gt;corruptFile);
 	Datum_free(self-&gt;unusedPid);
-	Pool_free(self-&gt;pool);
 	self-&gt;yajl = 0x0;
 	free(self);
 }
@@ -102,24 +98,13 @@ void PDB_free(PDB *self)
 
 PNode *PDB_allocNode(PDB *self)
 {
-	PNode *node = POOL_ALLOC(self-&gt;pool, PNode);
+	PNode *node = PNode_poolNew();
 	PNode_setPdb_(node, self);
 	PNode_setToRoot(node);
-	assert(self-&gt;yajl);
 	PNode_setYajl_(node, self-&gt;yajl);
 	return node;
 }
 
-Datum *PDB_allocDatum(PDB *self)
-{
-	return POOL_ALLOC(self-&gt;pool, Datum);
-}
-
-void PDB_freeNodes(PDB *self)
-{
-	Pool_freeRefs(self-&gt;pool);
-}
-
 // open/close ------------
 
 void PDB_setPathCString_(PDB *self, const char *path)</diff>
      <filename>source/pdb/PDB.c</filename>
    </modified>
    <modified>
      <diff>@@ -35,7 +35,6 @@ typedef struct
 	
 	Datum *currentUser;
 		
-	Pool *pool;
 	yajl_gen yajl;
 } PDB;
 
@@ -45,7 +44,6 @@ void PDB_free(PDB *self);
 
 // node caching -------------
 PNode *PDB_allocNode(PDB *self);
-Datum *PDB_allocDatum(PDB *self);
 void PDB_freeNodes(PDB *self);
 
 // open/close ------------</diff>
      <filename>source/pdb/PDB.h</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,13 @@
 
 #define PNODE_ID_LENGTH 9
 
+#include &quot;Pool.h&quot;
+
+PNode *PNode_poolNew(void)
+{
+	return GLOBAL_POOL_ALLOC(PNode)
+}
+
 PNode *PNode_new(void)
 {
 	PNode *self = calloc(1, sizeof(PNode));
@@ -1051,7 +1058,7 @@ int PNode_op_html(PNode *self, Datum *d)
 
 Datum *PNode_metaSlotFor_(PNode *self, Datum *key)
 {
-	Datum *d = PDB_allocDatum(self-&gt;pdb);
+	Datum *d = Datum_poolNew();
 	Datum_copy_(d, self-&gt;pid);
 	Datum_appendCString_(d, &quot;/m/&quot;);
 	Datum_append_(d, key);
@@ -1080,7 +1087,7 @@ Datum *PNode_metaAt_(PNode *self, Datum *d)
 		
 		if (v)
 		{
-			Datum *value = PDB_allocDatum(self-&gt;pdb);
+			Datum *value = Datum_poolNew();
 			Datum_setData_size_(value, v, vSize);
 			return value;
 		}</diff>
      <filename>source/pdb/PNode.c</filename>
    </modified>
    <modified>
      <diff>@@ -43,7 +43,9 @@ typedef struct
 
 typedef int (PNodeOp)(PNode *, Datum *);
 
+
 // creation and setup
+PNode *PNode_poolNew(void);
 PNode *PNode_new(void);
 void PNode_setYajl_(PNode *self, yajl_gen y);
 void PNode_setPdb_(PNode *self, void *pdb);</diff>
      <filename>source/pdb/PNode.h</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,32 @@
 #include &lt;stdlib.h&gt;
 #include &lt;time.h&gt;
 
+static Pool *globalPool = 0x0;
+
+Pool *Pool_globalPool(void)
+{
+	if(!globalPool) 
+	{
+		globalPool = Pool_new();
+	}
+	
+	return globalPool;
+}
+
+void Pool_globalPoolFreeRefs(void)
+{
+	Pool_freeRefs(Pool_globalPool());
+}
+
+void Pool_freeGlobalPool(void)
+{
+	if(globalPool)
+	{
+		Pool_free(globalPool);
+		globalPool = 0x0;
+	}
+}
+
 Pool *Pool_new(void)
 {
 	Pool *self = calloc(1, sizeof(Pool));</diff>
      <filename>source/pdb/Pool.c</filename>
    </modified>
    <modified>
      <diff>@@ -17,12 +17,17 @@ typedef struct
 typedef void *(PoolNewFunc)(void);
 typedef void (PoolFreeFunc)(void *);
 
+Pool *Pool_globalPool(void);
+void Pool_globalPoolFreeRefs(void);
+void Pool_freeGlobalPool(void);
+
 Pool *Pool_new(void);
 void Pool_free(Pool *self);
 void Pool_freeRefs(Pool *self);
 void *Pool_alllocWithNewAndFree(Pool *self, PoolNewFunc *newFunc, PoolFreeFunc *freeFunc);
 
 #define POOL_ALLOC(self, name) Pool_alllocWithNewAndFree(self, (PoolNewFunc *)name##_new, (PoolFreeFunc *)name##_free)
+#define GLOBAL_POOL_ALLOC(name) POOL_ALLOC(Pool_globalPool(), name);
 
 #ifdef __cplusplus
 }</diff>
      <filename>source/pdb/Pool.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,6 @@
 #include &quot;Yajl_extras.h&quot;
+#include &lt;stdio.h&gt;
+#include &lt;string.h&gt;
 
 void yajl_gen_cstring(yajl_gen self, const char *s)
 {</diff>
      <filename>source/pdb/Yajl_extras.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>19a9277ef8973352ba74bc0f45be535f9fdc2ba0</id>
    </parent>
    <parent>
      <id>227447f8fec48e64db5da597839b37b1654554c6</id>
    </parent>
  </parents>
  <author>
    <name>Rich Collins</name>
    <email>richcollins@gmail.com</email>
  </author>
  <url>http://github.com/hassy/vertexdb/commit/fa9757e044e9f75199efb997ea09c219161cb589</url>
  <id>fa9757e044e9f75199efb997ea09c219161cb589</id>
  <committed-date>2009-10-30T11:48:19-07:00</committed-date>
  <authored-date>2009-10-30T11:48:19-07:00</authored-date>
  <message>Merge branch 'master' of git://github.com/stevedekorte/vertexdb</message>
  <tree>3ea801837886e38a2f5733b6950e7f1bed608c5f</tree>
  <committer>
    <name>Rich Collins</name>
    <email>richcollins@gmail.com</email>
  </committer>
</commit>
