mirror of
https://github.com/darlinghq/darling-libobjc2.git
synced 2024-11-23 12:19:44 +00:00
bc87ed22e1
ARC functions are all now exposed in a header, but not yet documented. See the ARC ABI spec for now: http://clang.llvm.org/docs/AutomaticReferenceCounting.html#runtime
35 lines
536 B
C
35 lines
536 B
C
#include <string.h>
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* Efficient string hash function.
|
|
*/
|
|
__attribute__((unused))
|
|
static uint32_t string_hash(const char *str)
|
|
{
|
|
uint32_t hash = 0;
|
|
int32_t c;
|
|
while ((c = *str++))
|
|
{
|
|
hash = c + (hash << 6) + (hash << 16) - hash;
|
|
}
|
|
return hash;
|
|
}
|
|
|
|
/**
|
|
* Test two strings for equality.
|
|
*/
|
|
__attribute__((unused))
|
|
static int string_compare(const char *str1, const char *str2)
|
|
{
|
|
if (str1 == str2)
|
|
{
|
|
return 1;
|
|
}
|
|
if (str1 == NULL || str2 == NULL)
|
|
{
|
|
return 0;
|
|
}
|
|
return strcmp(str1, str2) == 0;
|
|
}
|