[FFmpeg-cvslog] url: add ffurl_closep() which also sets the context pointer to NULL

Michael Niedermayer git at videolan.org
Fri Jun 1 14:54:11 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Jun  1 14:47:30 2012 +0200| [edf96d631c000d1810be42649891bfddb9754427] | committer: Michael Niedermayer

url: add ffurl_closep() which also sets the context pointer to NULL

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=edf96d631c000d1810be42649891bfddb9754427
---

 libavformat/avio.c |   11 +++++++++--
 libavformat/url.h  |    3 ++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 5a1c79e..8b7e495 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -315,8 +315,9 @@ int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
     return ret;
 }
 
-int ffurl_close(URLContext *h)
+int ffurl_closep(URLContext **hh)
 {
+    URLContext *h= *hh;
     int ret = 0;
     if (!h) return 0; /* can happen when ffurl_open fails */
 
@@ -331,10 +332,16 @@ int ffurl_close(URLContext *h)
             av_opt_free(h->priv_data);
         av_freep(&h->priv_data);
     }
-    av_free(h);
+    av_freep(hh);
     return ret;
 }
 
+int ffurl_close(URLContext *h)
+{
+    return ffurl_closep(&h);
+}
+
+
 int avio_check(const char *url, int flags)
 {
     URLContext *h;
diff --git a/libavformat/url.h b/libavformat/url.h
index 6ad754e..82f42e8 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -179,11 +179,12 @@ int64_t ffurl_seek(URLContext *h, int64_t pos, int whence);
 
 /**
  * Close the resource accessed by the URLContext h, and free the
- * memory used by it.
+ * memory used by it. Also set the URLContext pointer to NULL.
  *
  * @return a negative value if an error condition occurred, 0
  * otherwise
  */
+int ffurl_closep(URLContext **h);
 int ffurl_close(URLContext *h);
 
 /**



More information about the ffmpeg-cvslog mailing list