diff options
author | Mattias Andrée <maandree@kth.se> | 2016-07-16 16:05:48 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-07-16 16:05:48 +0200 |
commit | c5a454342f78eec4c58b1477d9190a084f40cfac (patch) | |
tree | 3f98b7e6412182942bc36d44402790541d91fcea /src/util.c | |
parent | The stuff around supportinf SIGRTMIN+0 and SIGRTMIN+1 (diff) | |
download | coopgammad-c5a454342f78eec4c58b1477d9190a084f40cfac.tar.gz coopgammad-c5a454342f78eec4c58b1477d9190a084f40cfac.tar.bz2 coopgammad-c5a454342f78eec4c58b1477d9190a084f40cfac.tar.xz |
attributes
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | src/util.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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}; |