[vlc-commits] input: Move attachment functions in their own source file
Hugo Beauzée-Luyssen
git at videolan.org
Thu Nov 19 11:00:14 CET 2020
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Oct 27 16:49:46 2020 +0100| [d55a165d98ed3927c4591df84248abe81ff1aec1] | committer: Hugo Beauzée-Luyssen
input: Move attachment functions in their own source file
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d55a165d98ed3927c4591df84248abe81ff1aec1
---
include/vlc_input.h | 49 +++++-----------------------------
src/Makefile.am | 1 +
src/input/attachment.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/libvlccore.sym | 3 +++
4 files changed, 82 insertions(+), 42 deletions(-)
diff --git a/include/vlc_input.h b/include/vlc_input.h
index 21186f5239..2c0c4b1718 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -165,50 +165,15 @@ struct input_attachment_t
void *p_data;
};
-static inline void vlc_input_attachment_Delete( input_attachment_t *a )
-{
- if( !a )
- return;
-
- free( a->p_data );
- free( a->psz_description );
- free( a->psz_mime );
- free( a->psz_name );
- free( a );
-}
-
-static inline input_attachment_t *vlc_input_attachment_New( const char *psz_name,
- const char *psz_mime,
- const char *psz_description,
- const void *p_data,
- size_t i_data )
-{
- input_attachment_t *a = (input_attachment_t *)malloc( sizeof (*a) );
- if( unlikely(a == NULL) )
- return NULL;
+VLC_API void vlc_input_attachment_Delete( input_attachment_t *a );
- a->psz_name = strdup( psz_name ? psz_name : "" );
- a->psz_mime = strdup( psz_mime ? psz_mime : "" );
- a->psz_description = strdup( psz_description ? psz_description : "" );
- a->i_data = i_data;
- a->p_data = malloc( i_data );
- if( i_data > 0 && likely(a->p_data != NULL) )
- memcpy( a->p_data, p_data, i_data );
+VLC_API input_attachment_t *vlc_input_attachment_New( const char *psz_name,
+ const char *psz_mime,
+ const char *psz_description,
+ const void *p_data,
+ size_t i_data );
- if( unlikely(a->psz_name == NULL || a->psz_mime == NULL
- || a->psz_description == NULL || (i_data > 0 && a->p_data == NULL)) )
- {
- vlc_input_attachment_Delete( a );
- a = NULL;
- }
- return a;
-}
-
-static inline input_attachment_t *vlc_input_attachment_Duplicate( const input_attachment_t *a )
-{
- return vlc_input_attachment_New( a->psz_name, a->psz_mime, a->psz_description,
- a->p_data, a->i_data );
-}
+VLC_API input_attachment_t *vlc_input_attachment_Duplicate( const input_attachment_t *a );
/**
* Input rate.
diff --git a/src/Makefile.am b/src/Makefile.am
index 5e691b1b01..49947dc6be 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -265,6 +265,7 @@ libvlccore_la_SOURCES = \
input/input.c \
input/info.h \
input/meta.c \
+ input/attachment.c \
player/player.c \
player/player.h \
player/input.c \
diff --git a/src/input/attachment.c b/src/input/attachment.c
new file mode 100644
index 0000000000..1f9f2faf45
--- /dev/null
+++ b/src/input/attachment.c
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * attachment.c: Input attachments
+ *****************************************************************************
+ * Copyright (C) 1999-2020 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_input.h>
+
+void vlc_input_attachment_Delete( input_attachment_t *a )
+{
+ if( !a )
+ return;
+
+ free( a->p_data );
+ free( a->psz_description );
+ free( a->psz_mime );
+ free( a->psz_name );
+ free( a );
+}
+
+input_attachment_t *vlc_input_attachment_New( const char *psz_name,
+ const char *psz_mime,
+ const char *psz_description,
+ const void *p_data,
+ size_t i_data )
+{
+ input_attachment_t *a = (input_attachment_t *)malloc( sizeof (*a) );
+ if( unlikely(a == NULL) )
+ return NULL;
+
+ a->psz_name = strdup( psz_name ? psz_name : "" );
+ a->psz_mime = strdup( psz_mime ? psz_mime : "" );
+ a->psz_description = strdup( psz_description ? psz_description : "" );
+ a->i_data = i_data;
+ a->p_data = malloc( i_data );
+ if( i_data > 0 && likely(a->p_data != NULL) )
+ memcpy( a->p_data, p_data, i_data );
+
+ if( unlikely(a->psz_name == NULL || a->psz_mime == NULL
+ || a->psz_description == NULL || (i_data > 0 && a->p_data == NULL)) )
+ {
+ vlc_input_attachment_Delete( a );
+ a = NULL;
+ }
+ return a;
+}
+
+input_attachment_t *vlc_input_attachment_Duplicate( const input_attachment_t *a )
+{
+ return vlc_input_attachment_New( a->psz_name, a->psz_mime, a->psz_description,
+ a->p_data, a->i_data );
+}
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index c4d5273dbd..5bda357ef0 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -981,3 +981,6 @@ vlc_executor_Delete
vlc_executor_Submit
vlc_executor_Cancel
vlc_executor_WaitIdle
+vlc_input_attachment_Delete
+vlc_input_attachment_New
+vlc_input_attachment_Duplicate
More information about the vlc-commits
mailing list