Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/dav1d/dav1d.h4
-rw-r--r--src/lib.c9
-rw-r--r--tools/dav1d.c2
3 files changed, 9 insertions, 6 deletions
diff --git a/include/dav1d/dav1d.h b/include/dav1d/dav1d.h
index 9ce476d..d9965eb 100644
--- a/include/dav1d/dav1d.h
+++ b/include/dav1d/dav1d.h
@@ -80,8 +80,8 @@ DAV1D_API int dav1d_open(Dav1dContext **c_out, const Dav1dSettings *s);
DAV1D_API int dav1d_decode(Dav1dContext *c, Dav1dData *in, Dav1dPicture *out);
/**
- * Close decoder instance, free all associated memory.
+ * Close decoder instance, free all associated memory, and set $c_out to NULL.
*/
-DAV1D_API void dav1d_close(Dav1dContext *c);
+DAV1D_API void dav1d_close(Dav1dContext **c_out);
#endif /* __DAV1D_H__ */
diff --git a/src/lib.c b/src/lib.c
index 91a794d..33a5162 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -209,8 +209,11 @@ int dav1d_decode(Dav1dContext *const c,
return -EAGAIN;
}
-void dav1d_close(Dav1dContext *const c) {
- validate_input(c != NULL);
+void dav1d_close(Dav1dContext **const c_out) {
+ validate_input(c_out != NULL);
+
+ Dav1dContext *const c = *c_out;
+ if (!c) return;
for (int n = 0; n < c->n_fc; n++) {
Dav1dFrameContext *const f = &c->fc[n];
@@ -295,5 +298,5 @@ void dav1d_close(Dav1dContext *const c) {
if (c->refs[n].segmap)
dav1d_ref_dec(c->refs[n].segmap);
}
- dav1d_free_aligned(c);
+ dav1d_freep_aligned(c_out);
}
diff --git a/tools/dav1d.c b/tools/dav1d.c
index 9bfd66c..bc4d6af 100644
--- a/tools/dav1d.c
+++ b/tools/dav1d.c
@@ -167,7 +167,7 @@ int main(const int argc, char *const *const argv) {
fprintf(stderr, "No data decoded\n");
res = 1;
}
- dav1d_close(c);
+ dav1d_close(&c);
return res;
}