Add str_cmp() and use restrict
This commit is contained in:
14
common.h
14
common.h
@@ -43,7 +43,7 @@ static inline void byte_copy (void *dst, const void *src, size_t size)
|
|||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t str_cpy (char *dst, const char *src, size_t len)
|
static inline size_t str_cpy (char *restrict dst, const char *restrict src, size_t len)
|
||||||
{
|
{
|
||||||
if (!dst || !src)
|
if (!dst || !src)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -58,6 +58,18 @@ static inline size_t str_cpy (char *dst, const char *src, size_t len)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int str_cmp (const char *restrict sa, const char *restrict sb)
|
||||||
|
{
|
||||||
|
if (!sa || !sb)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
while (*sa==*sb++)
|
||||||
|
if (!*sa++)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct buffer buffer_t;
|
typedef struct buffer buffer_t;
|
||||||
|
|
||||||
struct buffer {
|
struct buffer {
|
||||||
|
|||||||
Reference in New Issue
Block a user