Skip to content

Commit

Permalink
moved strdupa from compat/misc to strings
Browse files Browse the repository at this point in the history
\+ missing include guard
  • Loading branch information
MartinPulec committed Jun 12, 2024
1 parent f01e4c3 commit e494106
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/audio/capture/portaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct module;
#include "audio/audio_capture.h"
#include "audio/portaudio_common.h"
#include "audio/types.h"
#include "compat/misc.h" // strdupa
#include "compat/strings.h" // strdupa
#include "debug.h"
#include "host.h"
#include "lib_common.h"
Expand Down
2 changes: 1 addition & 1 deletion src/audio/codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include "audio/codec.h"
#include "audio/utils.h"
#include "compat/misc.h"
#include "compat/strings.h" // strdupa
#include "debug.h"
#include "lib_common.h"
#include "utils/macros.h"
Expand Down
2 changes: 1 addition & 1 deletion src/audio/playback/portaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct device_info;
#include "audio/audio_playback.h"
#include "audio/portaudio_common.h"
#include "audio/types.h"
#include "compat/misc.h" // strdupa
#include "compat/strings.h" // for strdupa
#include "debug.h"
#include "host.h" // for get_commandline_param, INIT_NOERR
#include "lib_common.h"
Expand Down
2 changes: 1 addition & 1 deletion src/capture_filter/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#endif /* HAVE_CONFIG_H */

#include "capture_filter.h"
#include "compat/misc.h"
#include "compat/strings.h" // strdupa
#include "debug.h"
#include "lib_common.h"
#include "utils/color_out.h"
Expand Down
2 changes: 1 addition & 1 deletion src/capture_filter/override_prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#include "capture_filter.h"

#include "compat/misc.h"
#include "compat/strings.h" // for strdupa
#include "debug.h"
#include "lib_common.h"
#include "utils/color_out.h"
Expand Down
6 changes: 0 additions & 6 deletions src/compat/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
#ifndef COMPAT_MISC_H_20C709DB_F4A8_4744_A0A9_96036B277011
#define COMPAT_MISC_H_20C709DB_F4A8_4744_A0A9_96036B277011

// strdupa is defined as a macro
#include <string.h>
#ifndef strdupa
#define strdupa(s) (char *) memcpy(alloca(strlen(s) + 1), s, strlen(s) + 1)
#endif // defined strdupa

#ifdef WANT_MKDIR
#ifdef _WIN32
#include <direct.h>
Expand Down
15 changes: 13 additions & 2 deletions src/compat/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file compat/strings.h
* @author Martin Pulec <[email protected]>
*
* compatibility header for strcasecmp. strerror_s
* compatibility header for strcasecmp. strdup, strerror_s
*/
/*
* Copyright (c) 2024 CESNET
Expand Down Expand Up @@ -37,9 +37,13 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef COMPAT_STRINGS_H_D54CAFC8_A1A0_4FF5_80A0_91F34FB11E12
#define COMPAT_STRINGS_H_D54CAFC8_A1A0_4FF5_80A0_91F34FB11E12

#include <string.h>

#ifdef _WIN32
#ifndef strcasecmp
#include <string.h>
#define strcasecmp _stricmp
#endif
#else // ! defined _WIN32
Expand All @@ -64,5 +68,12 @@ COMPAT_MISC_EXT_C int __xpg_strerror_r(int errcode, char *buffer, size_t length)
#endif // ! defined __STDC_LIB_EXT1__
#endif // ! defined _WIN32

// strdupa is defined as a macro
#include <string.h>
#ifndef strdupa
#define strdupa(s) (char *) memcpy(alloca(strlen(s) + 1), s, strlen(s) + 1)
#endif // defined strdupa

#undef COMPAT_MISC_EXT_C

#endif // ! defined COMPAT_STRINGS_H_D54CAFC8_A1A0_4FF5_80A0_91F34FB11E12
1 change: 1 addition & 0 deletions src/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h> // for NULL, free, calloc, strtol
#include <string.h> // for strdup
#include <sys/types.h>
#include <time.h>

Expand Down
2 changes: 1 addition & 1 deletion src/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#include "audio/codec.h"
#include "audio/audio_filter.h"
#include "audio/utils.h"
#include "compat/misc.h"
#include "compat/strings.h" // strdupa
#include "compat/platform_pipe.h"
#include "debug.h"
#include "keyboard_control.h"
Expand Down
2 changes: 1 addition & 1 deletion src/video_rxtx/h264_rtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <cstring>
#include <memory>

#include "compat/misc.h"
#include "compat/strings.h" // strdupa
#include "debug.h"
#include "host.h"
#include "lib_common.h"
Expand Down

0 comments on commit e494106

Please sign in to comment.