aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/helpers.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-04-03 13:46:09 -0700
committerChris Robinson <[email protected]>2014-04-03 13:46:09 -0700
commit569374da2c5f310d9309d477c24627133110dad0 (patch)
treecfac2a35e826273d71a13cda0daa1ceaae4ffbd4 /Alc/helpers.c
parent482fb37b688b94f5aff78a8dc34e78c1e2840058 (diff)
Properly compare al_strings
Diffstat (limited to 'Alc/helpers.c')
-rw-r--r--Alc/helpers.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 837b19ad..8f6420d1 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -84,6 +84,7 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80,
#endif
#include "alMain.h"
+#include "alu.h"
#include "atomic.h"
#include "uintmap.h"
#include "vector.h"
@@ -799,8 +800,6 @@ ALboolean vector_resize(void *ptr, size_t base_size, size_t obj_count, size_t ob
extern inline ALsizei al_string_length(const_al_string str);
extern inline ALsizei al_string_empty(const_al_string str);
extern inline const al_string_char_type *al_string_get_cstr(const_al_string str);
-extern inline int al_string_cmp(const_al_string str1, const_al_string str2);
-extern inline int al_string_cmp_cstr(const_al_string str1, const al_string_char_type *str2);
void al_string_clear(al_string *str)
{
@@ -812,6 +811,29 @@ void al_string_clear(al_string *str)
*VECTOR_ITER_END(*str) = 0;
}
+static inline int al_string_compare(const al_string_char_type *str1, ALsizei str1len,
+ const al_string_char_type *str2, ALsizei str2len)
+{
+ ALsizei complen = mini(str1len, str2len);
+ int ret = memcmp(str1, str2, complen);
+ if(ret == 0)
+ {
+ if(str1len > str2len) return 1;
+ if(str1len < str2len) return -1;
+ }
+ return ret;
+}
+int al_string_cmp(const_al_string str1, const_al_string str2)
+{
+ return al_string_compare(&VECTOR_FRONT(str1), al_string_length(str1),
+ &VECTOR_FRONT(str2), al_string_length(str2));
+}
+int al_string_cmp_cstr(const_al_string str1, const al_string_char_type *str2)
+{
+ return al_string_compare(&VECTOR_FRONT(str1), al_string_length(str1),
+ str2, (ALsizei)strlen(str2));
+}
+
void al_string_copy(al_string *str, const_al_string from)
{
ALsizei len = VECTOR_SIZE(from);