From c5a454342f78eec4c58b1477d9190a084f40cfac Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 16 Jul 2016 16:05:48 +0200 Subject: attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/util.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index cb04154..c116998 100644 --- a/src/util.c +++ b/src/util.c @@ -34,7 +34,7 @@ * @return The duplicate of the memory segment, * `NULL` on error */ -void* memdup(const void* src, size_t n) +void* memdup(const void* restrict src, size_t n) { void* dest = malloc(n); if (dest == NULL) @@ -52,7 +52,7 @@ void* memdup(const void* src, size_t n) * @return The read content, plus a NUL byte at * the end (not counted in `*n`) */ -void* nread(int fd, size_t* n) +void* nread(int fd, size_t* restrict n) { size_t size = 32; ssize_t got; @@ -113,9 +113,9 @@ void* nread(int fd, size_t* n) * @return The number of written bytes, less than `n` * on error, cannot exceed `n` */ -size_t nwrite(int fd, const void* buf, size_t n) +size_t nwrite(int fd, const void* restrict buf, size_t n) { - const char* bs = buf; + const char* restrict bs = buf; ssize_t wrote; size_t ptr = 0; @@ -189,6 +189,7 @@ void msleep(int ms) nanosleep(&ts, NULL); } + /** * Check whether a NUL-terminated string is encoded in UTF-8 * @@ -196,7 +197,7 @@ void msleep(int ms) * @param allow_modified_nul Whether Modified UTF-8 is allowed, which allows a two-byte encoding for NUL * @return Zero if good, -1 on encoding error */ -int verify_utf8(const char* string, int allow_modified_nul) +int verify_utf8(const char* restrict string, int allow_modified_nul) { static long BYTES_TO_MIN_BITS[] = {0, 0, 8, 12, 17, 22, 37}; static long BYTES_TO_MAX_BITS[] = {0, 7, 11, 16, 21, 26, 31}; -- cgit v1.2.3-70-g09d2