+// OJO to fail cleanly while doing a realloc\r
+// if we can't realloc we are pretty much screwed anyway but\r
+// it makes the code clearer to not have a bunch of if (!ptr) { printf("..."); exit(1); };\r
+inline void * urealloc(void *ptr, size_t size){\r
+\r
+ void * dest = realloc(ptr,size);\r
+ //don't fail if we requested size 0\r
+ if (dest == NULL && size > 0 )\r
+ throw std::bad_alloc();\r
+ return dest;\r
+\r
+}\r
+\r
+inline void * ucalloc(size_t nmemb, size_t size){\r
+\r
+ void * dest = calloc(nmemb,size);\r
+ //don't fail if we requested size 0\r
+ if (dest == NULL && nmemb > 0 && size > 0 )\r
+ throw std::bad_alloc();\r
+ return dest;\r
+\r
+}\r
+\r
+inline void * umalloc(size_t size){\r
+ void * dest = malloc(size);\r
+ if (dest == NULL && size > 0)\r
+ throw std::bad_alloc();\r
+ return dest;\r
+}\r
+\r
+void XMLTree::print_stats() {\r
+ uint total_space = Tags->size()+sizeof(static_sequence*);\r
+ total_space += sizeof(uint*)+sizeof(uint)*(2+uint_len(tags_blen,tags_len));\r
+ cout << "Space usage for XMLTree:" << endl\r
+ << " - tags static_sequence: " << Tags->size()+sizeof(static_sequence*) << endl\r
+ << " - tags access array: " << sizeof(uint*)+sizeof(uint)*(2+uint_len(tags_blen,tags_len)) << endl\r
+ << " ... add Diego structures ... " << endl\r
+ << " *total* " << total_space << endl;\r
+}\r
+\r