This commit is contained in:
Kovid Goyal 2017-09-28 11:15:53 +05:30
parent 7d6d8efc26
commit b4a96428f3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 8 additions and 14 deletions

View File

@ -42,7 +42,7 @@ grman_realloc(GraphicsManager *old, index_type lines, index_type columns) {
} else {
self->images_capacity = old->images_capacity; self->images = old->images; self->image_count = old->image_count;
old->images = NULL;
grman_free(old);
Py_DECREF(old);
}
return self;
}
@ -64,12 +64,13 @@ free_image(Image *img) {
free_load_data(&(img->load_data));
}
GraphicsManager*
grman_free(GraphicsManager* self) {
for (size_t i = 0; i < self->image_count; i++) free_image(self->images + i);
free(self->images);
static void
dealloc(GraphicsManager* self) {
if (self->images) {
for (size_t i = 0; i < self->image_count; i++) free_image(self->images + i);
free(self->images);
}
Py_TYPE(self)->tp_free((PyObject*)self);
return NULL;
}
static size_t internal_id_counter = 1;
@ -426,11 +427,6 @@ new(PyTypeObject UNUSED *type, PyObject *args, PyObject UNUSED *kwds) {
return ans;
}
static void
dealloc(GraphicsManager* self) {
grman_free(self);
}
static inline PyObject*
image_as_dict(Image *img) {
#define U(x) #x, img->x

View File

@ -49,5 +49,4 @@ PyTypeObject GraphicsManager_Type;
GraphicsManager* grman_realloc(GraphicsManager *, index_type lines, index_type columns);
void grman_clear(GraphicsManager*);
GraphicsManager* grman_free(GraphicsManager*);
const char* grman_handle_command(GraphicsManager *self, const GraphicsCommand *g, const uint8_t *payload);

View File

@ -213,8 +213,7 @@ static void
dealloc(Screen* self) {
pthread_mutex_destroy(&self->read_buf_lock);
pthread_mutex_destroy(&self->write_buf_lock);
if (self->main_grman) { self->main_grman = grman_free(self->main_grman); }
if (self->alt_grman) { self->alt_grman = grman_free(self->alt_grman); }
Py_CLEAR(self->grman); Py_CLEAR(self->alt_grman);
PyMem_RawFree(self->write_buf);
Py_CLEAR(self->callbacks);
Py_CLEAR(self->test_child);