Skip to content

Commit

Permalink
[core] Fix name conflict with md5 functions (#2301)
Browse files Browse the repository at this point in the history
by wrapping internal md5 functions inside the srt namespace.
  • Loading branch information
Biswa96 authored Apr 20, 2022
1 parent c0da44e commit 911de75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 8 additions & 0 deletions srtcore/md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
#include "md5.h"
#include <string.h>

/*
* All symbols have been put under the srt namespace
* to avoid potential linkage conflicts.
*/
namespace srt {

#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
#ifdef ARCH_IS_BIG_ENDIAN
# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
Expand Down Expand Up @@ -379,3 +385,5 @@ md5_finish(md5_state_t *pms, md5_byte_t digest[16])
for (i = 0; i < 16; ++i)
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}

} // namespace srt
15 changes: 7 additions & 8 deletions srtcore/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
#ifndef md5_INCLUDED
# define md5_INCLUDED

/*
* All symbols have been put under the srt namespace
* to avoid potential linkage conflicts.
*/
namespace srt {

/*
* This package supports both compile-time and run-time determination of CPU
* byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
Expand All @@ -70,11 +76,6 @@ typedef struct md5_state_s {
md5_byte_t buf[64]; /* accumulate block */
} md5_state_t;

#ifdef __cplusplus
extern "C"
{
#endif

/* Initialize the algorithm. */
void md5_init(md5_state_t *pms);

Expand All @@ -84,8 +85,6 @@ void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
/* Finish the message and return the digest. */
void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);

#ifdef __cplusplus
} /* end extern "C" */
#endif
} // namespace srt

#endif /* md5_INCLUDED */

0 comments on commit 911de75

Please sign in to comment.