Add str_cmp() and use restrict

This commit is contained in:
angt
2015-10-20 23:49:00 +02:00
parent 796d804f33
commit a2a9973f5f

View File

@@ -43,7 +43,7 @@ static inline void byte_copy (void *dst, const void *src, size_t size)
*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)
return 0;
@@ -58,6 +58,18 @@ static inline size_t str_cpy (char *dst, const char *src, size_t len)
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;
struct buffer {