From d7f15ac7306a80fee78631d6ff2d736d125f6414 Mon Sep 17 00:00:00 2001 From: waker Date: Fri, 30 Aug 2013 20:19:26 +0200 Subject: moved all copies of strdupa macro to strdupa.h --- plugins/converter/converter.c | 11 +---------- plugins/ffmpeg/ffmpeg.c | 1 + plugins/gtkui/hotkeys.c | 11 +---------- plugins/gtkui/widgets.c | 10 +--------- strdupa.h | 18 ++++++++++++++++++ streamer.c | 11 +---------- 6 files changed, 23 insertions(+), 39 deletions(-) create mode 100644 strdupa.h diff --git a/plugins/converter/converter.c b/plugins/converter/converter.c index d0f4b2eb..e26e7e6b 100644 --- a/plugins/converter/converter.c +++ b/plugins/converter/converter.c @@ -34,16 +34,7 @@ #include #include "converter.h" #include "../../deadbeef.h" - -#ifndef strdupa -# define strdupa(s) \ - ({ \ - const char *old = (s); \ - size_t len = strlen (old) + 1; \ - char *new = (char *) alloca (len); \ - (char *) memcpy (new, old, len); \ - }) -#endif +#include "../../strdupa.h" #ifndef __linux__ #define O_LARGEFILE 0 diff --git a/plugins/ffmpeg/ffmpeg.c b/plugins/ffmpeg/ffmpeg.c index 160f2d33..41d75d53 100644 --- a/plugins/ffmpeg/ffmpeg.c +++ b/plugins/ffmpeg/ffmpeg.c @@ -24,6 +24,7 @@ #include #include "../../deadbeef.h" +#include "../../strdupa.h" #if !FFMPEG_OLD diff --git a/plugins/gtkui/hotkeys.c b/plugins/gtkui/hotkeys.c index 4b7ac034..a34fb629 100644 --- a/plugins/gtkui/hotkeys.c +++ b/plugins/gtkui/hotkeys.c @@ -61,16 +61,7 @@ typedef struct #include // only for the KeySym type #endif #include "hotkeys.h" - -#ifndef strdupa -# define strdupa(s) \ - ({ \ - const char *old = (s); \ - size_t len = strlen (old) + 1; \ - char *new = (char *) alloca (len); \ - (char *) memcpy (new, old, len); \ - }) -#endif +#include "../../strdupa.h" void on_hotkeys_actions_cursor_changed (GtkTreeView *treeview, diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c index 7318d894..e15fa0a4 100644 --- a/plugins/gtkui/widgets.c +++ b/plugins/gtkui/widgets.c @@ -37,19 +37,11 @@ #endif #include "namedicons.h" #include "hotkeys.h" // for building action treeview +#include "../../strdupa.h" #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) -#ifndef strdupa -# define strdupa(s) \ - ({ \ - const char *old = (s); \ - size_t len = strlen (old) + 1; \ - char *new = (char *) alloca (len); \ - (char *) memcpy (new, old, len); \ - }) -#endif // utility code for parsing keyvalues #define get_keyvalue(s,key,val) {\ diff --git a/strdupa.h b/strdupa.h new file mode 100644 index 00000000..00a94cb6 --- /dev/null +++ b/strdupa.h @@ -0,0 +1,18 @@ +#ifndef __DDB_PLATFORM_H +#define __DDB_PLATFORM_H + +#include + +#ifndef _GNU_SOURCE +#ifndef strdupa +# define strdupa(s) \ + ({ \ + const char *old = (s); \ + size_t len = strlen (old) + 1; \ + char *new = (char *) alloca (len); \ + (char *) memcpy (new, old, len); \ + }) +#endif +#endif + +#endif diff --git a/streamer.c b/streamer.c index 58e97172..54960e40 100644 --- a/streamer.c +++ b/streamer.c @@ -50,6 +50,7 @@ #include "fft.h" #include "handler.h" #include "plugins/libparser/parser.h" +#include "strdupa.h" //#define trace(...) { fprintf(stderr, __VA_ARGS__); } #define trace(fmt,...) @@ -57,16 +58,6 @@ //#define WRITE_DUMP 1 //#define DETECT_PL_LOCK_RC 1 -#ifndef strdupa -# define strdupa(s) \ - ({ \ - const char *old = (s); \ - size_t len = strlen (old) + 1; \ - char *new = (char *) alloca (len); \ - (char *) memcpy (new, old, len); \ - }) -#endif - #if WRITE_DUMP FILE *out; #endif -- cgit v1.2.3