mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-31 06:18:17 +00:00
DRYer
This commit is contained in:
parent
c973a7326e
commit
df1e06ec2c
2 changed files with 10 additions and 8 deletions
|
|
@ -56,9 +56,17 @@ free_load_data(LoadData *ld) {
|
|||
ld->fd = -1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
free_image(Image *img) {
|
||||
img->data_loaded = false;
|
||||
// TODO: free the texture if texture_id is not zero
|
||||
img->texture_id = 0;
|
||||
free_load_data(&(img->load_data));
|
||||
}
|
||||
|
||||
GraphicsManager*
|
||||
grman_free(GraphicsManager* self) {
|
||||
for (size_t i = 0; i < self->image_count; i++) free_load_data(&(self->images[i].load_data));
|
||||
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;
|
||||
|
|
@ -101,12 +109,6 @@ remove_from_array(void *array, size_t item_size, size_t idx, size_t array_count)
|
|||
memset(p + (item_size * (array_count - 1)), 0, item_size);
|
||||
}
|
||||
|
||||
static inline void
|
||||
free_image(Image *img) {
|
||||
img->data_loaded = false;
|
||||
free_load_data(&(img->load_data));
|
||||
}
|
||||
|
||||
static inline void
|
||||
remove_images(GraphicsManager *self, bool(*predicate)(Image*)) {
|
||||
for (size_t i = self->image_count; i-- > 0;) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ typedef struct {
|
|||
} LoadData;
|
||||
|
||||
typedef struct {
|
||||
uint32_t gl_id, client_id, width, height;
|
||||
uint32_t texture_id, client_id, width, height;
|
||||
size_t internal_id, refcnt;
|
||||
|
||||
bool data_loaded;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue