[vlc-devel] [PATCH 05/10] vout: control: setup the vout_control_cmd_t inline

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 17 13:50:48 CEST 2020


And don't use memset for such a simple thing.
---
 src/video_output/control.c | 41 +++++++++++++++-----------------------
 1 file changed, 16 insertions(+), 25 deletions(-)

diff --git a/src/video_output/control.c b/src/video_output/control.c
index 6ab8e6e27f0..459dea5b697 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -29,12 +29,6 @@
 #include "vout_internal.h"
 
 /* */
-static void vout_control_cmd_Init(vout_control_cmd_t *cmd, int type)
-{
-    memset(cmd, 0, sizeof(*cmd));
-    cmd->type = type;
-}
-
 void vout_control_cmd_Clean(vout_control_cmd_t *cmd)
 {
     switch (cmd->type) {
@@ -99,36 +93,33 @@ void vout_control_Wake(vout_control_t *ctrl)
 
 void vout_control_PushVoid(vout_control_t *ctrl, int type)
 {
-    vout_control_cmd_t cmd;
-
-    vout_control_cmd_Init(&cmd, type);
-    vout_control_Push(ctrl, &cmd);
+    vout_control_Push(ctrl, &(vout_control_cmd_t) {
+        .type = type,
+    });
 }
+
 void vout_control_PushBool(vout_control_t *ctrl, int type, bool boolean)
 {
-    vout_control_cmd_t cmd;
-
-    vout_control_cmd_Init(&cmd, type);
-    cmd.boolean = boolean;
-    vout_control_Push(ctrl, &cmd);
+    vout_control_Push(ctrl, &(vout_control_cmd_t) {
+        .type = type,
+        .boolean = boolean,
+    });
 }
 
 void vout_control_PushString(vout_control_t *ctrl, int type, const char *string)
 {
-    vout_control_cmd_t cmd;
-
-    vout_control_cmd_Init(&cmd, type);
-    cmd.string = string ? strdup(string) : NULL;
-    vout_control_Push(ctrl, &cmd);
+    vout_control_Push(ctrl, &(vout_control_cmd_t) {
+        .type = type,
+        .string = string ? strdup(string) : NULL,
+    });
 }
 
 void vout_control_PushMouse(vout_control_t *ctrl, int type, const vlc_mouse_t *mouse)
 {
-    vout_control_cmd_t cmd;
-
-    vout_control_cmd_Init(&cmd, type);
-    cmd.mouse = *mouse;
-    vout_control_Push(ctrl, &cmd);
+    vout_control_Push(ctrl, &(vout_control_cmd_t) {
+        .type = type,
+        .mouse = *mouse,
+    });
 }
 
 void vout_control_Hold(vout_control_t *ctrl)
-- 
2.26.2



More information about the vlc-devel mailing list