]> git.cworth.org Git - apitrace/commitdiff
Revert "Plug leaks in glretrace."
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 5 Oct 2011 07:05:26 +0000 (08:05 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 5 Oct 2011 07:05:26 +0000 (08:05 +0100)
This reverts commit 568b271fe00e9489761d2b96a89bdfbfd709953a, which got
committed by mistake, as it is still experimental work.

retrace.py
scoped_allocator.hpp [deleted file]

index edfc07977cf8f94ddac2b8ffb0afac96e2688423..724f5220bee23dd65b8d8008ac886e92dda43fb4 100644 (file)
@@ -70,7 +70,7 @@ class ValueExtractor(stdapi.Visitor):
         print '    const Trace::Array *__a%s = dynamic_cast<const Trace::Array *>(&%s);' % (array.id, rvalue)
         print '    if (__a%s) {' % (array.id)
         length = '__a%s->values.size()' % array.id
-        print '        __allocator(%s, %s);' % (lvalue, length)
+        print '        %s = new %s[%s];' % (lvalue, array.type, length)
         index = '__j' + array.id
         print '        for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)
         try:
@@ -84,7 +84,7 @@ class ValueExtractor(stdapi.Visitor):
     def visit_pointer(self, pointer, lvalue, rvalue):
         print '    const Trace::Array *__a%s = dynamic_cast<const Trace::Array *>(&%s);' % (pointer.id, rvalue)
         print '    if (__a%s) {' % (pointer.id)
-        print '        __allocator(%s);' % (lvalue,)
+        print '        %s = new %s;' % (lvalue, pointer.type)
         try:
             self.visit(pointer.type, '%s[0]' % (lvalue,), '*__a%s->values[0]' % (pointer.id,))
         finally:
@@ -193,8 +193,6 @@ class Retracer:
             print '    (void)call;'
             return
 
-        print '    scoped_allocator __allocator;'
-        print '    (void)__allocator;'
         success = True
         for arg in function.args:
             arg_type = ConstRemover().visit(arg.type)
@@ -280,7 +278,6 @@ class Retracer:
 
         print '#include "trace_parser.hpp"'
         print '#include "retrace.hpp"'
-        print '#include "scoped_allocator.hpp"'
         print
 
         types = api.all_types()
diff --git a/scoped_allocator.hpp b/scoped_allocator.hpp
deleted file mode 100644 (file)
index 6bd6d64..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef _SCOPED_ALLOCATOR_HPP_
-#define _SCOPED_ALLOCATOR_HPP_
-
-
-#include <stdlib.h>
-
-
-class scoped_allocator
-{
-private:
-    void *next;
-
-public:
-    scoped_allocator() : next(NULL) {
-    }
-
-    inline void *
-    alloc(size_t size) {
-        if (!size) {
-            return NULL;
-        }
-
-        void * * buf = (void * *)malloc(sizeof(void *) + size);
-        if (!buf) {
-            return NULL;
-        }
-
-        *buf = next;
-        next = buf;
-
-        return &buf[1];
-    }
-
-    template< class T >
-    inline void operator() (T * &ptr, size_t n = 1) {
-        ptr = (T *)alloc(sizeof(T) * n);
-    }
-
-    inline ~scoped_allocator() {
-        while (next) {
-            void *temp = *(void **)next;
-            free(next);
-            next = temp;
-        }
-    }
-};
-
-
-#endif