]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/python/as.c
python: Remove local stringpool and ctx from AS class
[people/ms/libloc.git] / src / python / as.c
index 4aad074fc653add9c7aab9d06ec2d74475f9ff76..44b959cdef7e04be13878aebc6bce0825dd9dc0e 100644 (file)
 
 #include <loc/libloc.h>
 #include <loc/as.h>
-#include <loc/stringpool.h>
 
 #include "locationmodule.h"
 #include "as.h"
 
-static PyObject* AS_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
-       // Create stringpool
-       struct loc_stringpool* pool;
-       int r = loc_stringpool_new(loc_ctx, &pool);
-       if (r)
-               return NULL;
-
+PyObject* new_as(PyTypeObject* type, struct loc_as* as) {
        ASObject* self = (ASObject*)type->tp_alloc(type, 0);
        if (self) {
-               self->ctx = loc_ref(loc_ctx);
-               self->pool = pool;
+               self->as = loc_as_ref(as);
        }
 
        return (PyObject*)self;
 }
 
+static PyObject* AS_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
+       ASObject* self = (ASObject*)type->tp_alloc(type, 0);
+
+       return (PyObject*)self;
+}
+
 static void AS_dealloc(ASObject* self) {
        if (self->as)
                loc_as_unref(self->as);
 
-       if (self->pool)
-               loc_stringpool_unref(self->pool);
-
-       if (self->ctx)
-               loc_unref(self->ctx);
-
        Py_TYPE(self)->tp_free((PyObject* )self);
 }
 
@@ -59,7 +51,7 @@ static int AS_init(ASObject* self, PyObject* args, PyObject* kwargs) {
                return -1;
 
        // Create the AS object
-       int r = loc_as_new(self->ctx, self->pool, &self->as, number);
+       int r = loc_as_new(loc_ctx, NULL, &self->as, number);
        if (r)
                return -1;