Use restrict on pointers where it makes sense. (requires C99 support,
which we already assume)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "ucore/string.h"
|
||||
|
||||
size_t
|
||||
uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler)
|
||||
uc_ascii2bcd(const char *restrict ascii, unsigned char *restrict bcdout, unsigned char filler)
|
||||
{
|
||||
unsigned char *bcdp = bcdout;
|
||||
int shift = 0;
|
||||
@@ -36,7 +36,7 @@ uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler)
|
||||
|
||||
static const char hex[] = "0123456789ABCDEF";
|
||||
size_t
|
||||
uc_bcd2ascii(const unsigned char *bcd, size_t bcdlen, char *asciiout)
|
||||
uc_bcd2ascii(const unsigned char *restrict bcd, size_t bcdlen, char *restrict asciiout)
|
||||
{
|
||||
size_t i;
|
||||
size_t idx = 0;
|
||||
|
||||
+7
-7
@@ -106,7 +106,7 @@ char *uc_dstr_put(struct DStr *str, size_t len)
|
||||
return start;
|
||||
}
|
||||
|
||||
size_t uc_dstr_put_str_filter(struct DStr *str, const char *s, int (*is_x)(int c))
|
||||
size_t uc_dstr_put_str_filter(struct DStr *str, const char *restrict s, int (*is_x)(int c))
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
size_t i;
|
||||
@@ -128,7 +128,7 @@ size_t uc_dstr_put_str_filter(struct DStr *str, const char *s, int (*is_x)(int c
|
||||
return idx;
|
||||
}
|
||||
|
||||
int uc_dstr_put_str_sz(struct DStr *str, const char *s, size_t len)
|
||||
int uc_dstr_put_str_sz(struct DStr *str, const char *restrict s, size_t len)
|
||||
{
|
||||
char *start = uc_dstr_put(str, len);
|
||||
|
||||
@@ -140,7 +140,7 @@ int uc_dstr_put_str_sz(struct DStr *str, const char *s, size_t len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uc_dstr_put_str(struct DStr *str, const char *s)
|
||||
int uc_dstr_put_str(struct DStr *str, const char *restrict s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
|
||||
@@ -159,7 +159,7 @@ int uc_dstr_put_char(struct DStr *str, char c)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void uc_dstr_own(struct DStr *str, char *s)
|
||||
void uc_dstr_own(struct DStr *str, char *restrict s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
|
||||
@@ -181,7 +181,7 @@ char *uc_dstr_steal(struct DStr *str)
|
||||
return s;
|
||||
}
|
||||
|
||||
void uc_str_swap(struct DStr *a, struct DStr *b)
|
||||
void uc_str_swap(struct DStr *restrict a, struct DStr *restrict b)
|
||||
{
|
||||
struct DStr tmp;
|
||||
|
||||
@@ -236,7 +236,7 @@ void uc_dstr_trim(struct DStr *str)
|
||||
}
|
||||
}
|
||||
|
||||
int uc_dstr_sprintf(struct DStr *str, const char *fmt, ...)
|
||||
int uc_dstr_sprintf(struct DStr *str, const char *restrict fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int rc;
|
||||
@@ -248,7 +248,7 @@ int uc_dstr_sprintf(struct DStr *str, const char *fmt, ...)
|
||||
return rc;
|
||||
}
|
||||
|
||||
int uc_dstr_vsprintf(struct DStr *str, const char *fmt, va_list ap_)
|
||||
int uc_dstr_vsprintf(struct DStr *str, const char *restrict fmt, va_list ap_)
|
||||
{
|
||||
va_list ap;
|
||||
int rc;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
static const char hx_chars[] = "0123456789ABCDEF" ;
|
||||
|
||||
char*
|
||||
uc_hex_encode(const uint8_t *in, size_t len, char *out)
|
||||
uc_hex_encode(const uint8_t *restrict in, size_t len, char *restrict out)
|
||||
{
|
||||
unsigned int i, t;
|
||||
|
||||
@@ -28,7 +28,7 @@ uc_hex_encode(const uint8_t *in, size_t len, char *out)
|
||||
}
|
||||
|
||||
char*
|
||||
uc_hex_encode_delim(const uint8_t *in, size_t inlen, char *out, int outlen, const char *delim)
|
||||
uc_hex_encode_delim(const uint8_t *restrict in, size_t inlen, char *restrict out, int outlen, const char *restrict delim)
|
||||
{
|
||||
size_t i;
|
||||
char *outp = out;
|
||||
@@ -76,7 +76,7 @@ static inline int char_to_bin(char c)
|
||||
}
|
||||
|
||||
uint8_t*
|
||||
uc_hex_decode(const char *in, size_t maxlen,uint8_t *out)
|
||||
uc_hex_decode(const char *restrict in, size_t maxlen,uint8_t *restrict out)
|
||||
{
|
||||
size_t i, t;
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ uint8_t *uc_mbuf_pull(struct MBuf *mbuf, uint32_t size)
|
||||
return data;
|
||||
}
|
||||
|
||||
void uc_mbuf_init(struct MBuf *mbuf, uint8_t *buf, uint32_t len, uint32_t headroom, uint32_t flags)
|
||||
void uc_mbuf_init(struct MBuf *mbuf, uint8_t *restrict buf, uint32_t len, uint32_t headroom, uint32_t flags)
|
||||
{
|
||||
mbuf->bufstart = buf;
|
||||
mbuf->p1 = mbuf->p2 = mbuf->p3 = mbuf->p4 = NULL;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include <string.h>
|
||||
|
||||
size_t uc_strlcpy(char *dst, const char *src, size_t max)
|
||||
size_t uc_strlcpy(char *restrict dst, const char *restrict src, size_t max)
|
||||
{
|
||||
size_t len = strlen(src);
|
||||
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ int uc_strv_check_expand(struct UCStrv *strv)
|
||||
return rc;
|
||||
}
|
||||
|
||||
int uc_strv_append(struct UCStrv *strv, const char *str)
|
||||
int uc_strv_append(struct UCStrv *strv, const char *restrict str)
|
||||
{
|
||||
int rc;
|
||||
char *dup;
|
||||
@@ -57,7 +57,7 @@ int uc_strv_append(struct UCStrv *strv, const char *str)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uc_strv_append_nocopy(struct UCStrv *strv, char *str)
|
||||
int uc_strv_append_nocopy(struct UCStrv *strv, char *restrict str)
|
||||
{
|
||||
int rc;
|
||||
rc = uc_strv_check_expand(strv);
|
||||
@@ -105,7 +105,7 @@ void uc_strv_destroy(struct UCStrv *strv)
|
||||
strv->strings = NULL;
|
||||
}
|
||||
|
||||
int uc_strv_append_all(struct UCStrv *a, struct UCStrv *b, int copy)
|
||||
int uc_strv_append_all(struct UCStrv *restrict a, struct UCStrv *restrict b, int copy)
|
||||
{
|
||||
size_t i;
|
||||
int rc;
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ const char *uc_val_2_str_bs(unsigned int val,
|
||||
return found;
|
||||
}
|
||||
|
||||
const char *uc_str_2_str(const char *val, const struct UCStrStr *array)
|
||||
const char *uc_str_2_str(const char *restrict val, const struct UCStrStr *array)
|
||||
{
|
||||
const char *found = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user