diff options
Diffstat (limited to 'backends/rng.c')
-rw-r--r-- | backends/rng.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/backends/rng.c b/backends/rng.c index 2f2f3ee4eb..014cb9d0fe 100644 --- a/backends/rng.c +++ b/backends/rng.c @@ -64,6 +64,30 @@ static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp) s->opened = true; } +static void rng_backend_free_request(RngRequest *req) +{ + g_free(req->data); + g_free(req); +} + +static void rng_backend_free_requests(RngBackend *s) +{ + GSList *i; + + for (i = s->requests; i; i = i->next) { + rng_backend_free_request(i->data); + } + + g_slist_free(s->requests); + s->requests = NULL; +} + +void rng_backend_finalize_request(RngBackend *s, RngRequest *req) +{ + s->requests = g_slist_remove(s->requests, req); + rng_backend_free_request(req); +} + static void rng_backend_init(Object *obj) { object_property_add_bool(obj, "opened", @@ -72,6 +96,13 @@ static void rng_backend_init(Object *obj) NULL); } +static void rng_backend_finalize(Object *obj) +{ + RngBackend *s = RNG_BACKEND(obj); + + rng_backend_free_requests(s); +} + static void rng_backend_class_init(ObjectClass *oc, void *data) { UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); @@ -84,6 +115,7 @@ static const TypeInfo rng_backend_info = { .parent = TYPE_OBJECT, .instance_size = sizeof(RngBackend), .instance_init = rng_backend_init, + .instance_finalize = rng_backend_finalize, .class_size = sizeof(RngBackendClass), .class_init = rng_backend_class_init, .abstract = true, |