diff mbox

[FFmpeg-devel,3/4] lavf/format: simplify I/O registration

Message ID 20171127043021.20321-3-atomnuker@gmail.com
State New
Headers show

Commit Message

Rostislav Pehlivanov Nov. 27, 2017, 4:30 a.m. UTC
Same as previous commit, unneded use of atomics.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
---
 libavformat/format.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/libavformat/format.c b/libavformat/format.c
index 38ca2a3465..6ac7349ec5 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -19,7 +19,6 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/atomic.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 #include "libavutil/opt.h"
@@ -62,9 +61,11 @@  void av_register_input_format(AVInputFormat *format)
 {
     AVInputFormat **p = last_iformat;
 
-    // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL
-    while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
-        p = &(*p)->next;
+    /* Iterate through the list until the last entry has been reached */
+    while (p != &format->next && !format->next) {
+        *p = format;
+        p  = &(format)->next;
+    }
 
     if (!format->next)
         last_iformat = &format->next;
@@ -74,9 +75,11 @@  void av_register_output_format(AVOutputFormat *format)
 {
     AVOutputFormat **p = last_oformat;
 
-    // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL
-    while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
-        p = &(*p)->next;
+    /* Iterate through the list until the last entry has been reached */
+    while (p != &format->next && !format->next) {
+        *p = format;
+        p  = &(format)->next;
+    }
 
     if (!format->next)
         last_oformat = &format->next;