slap restrict (almost) everywhere

This commit is contained in:
r4
2022-05-29 21:04:42 +02:00
parent 4da0422c5a
commit d2cd52b971
5 changed files with 14 additions and 14 deletions

View File

@@ -80,7 +80,7 @@ typedef struct Error {
/* Returns true if the given error structure actually contains a real error. */
static inline bool error_is(Error e) { return e.kind != ErrorNone; }
/* Same as error_is but takes a pointer and does NULL checking. */
static inline bool error_ptr_is(Error *e) { return e != NULL && e->kind != ErrorNone; }
static inline bool error_ptr_is(Error *restrict e) { return e != NULL && e->kind != ErrorNone; }
/* Call this at the beginning of any program that makes use of any of the more
* advanced error features (those which involve heap allocation). */
@@ -92,9 +92,9 @@ void error_term();
#include <ds/fmt.h>;
fmt("%{Error:destroy}", err);
*/
size_t error_to_string(char *buf, size_t size, Error e, bool destroy);
size_t error_to_string(char *restrict buf, size_t size, Error e, bool destroy);
Error *_error_heapify(Error e);
Error _error_hereify(const char *file, size_t line, Error e);
Error _error_hereify(const char *restrict file, size_t line, Error e);
#endif

View File

@@ -52,7 +52,7 @@ FUNCDECL(VTYPE *, _get)(NAME m, KTYPE key);
FUNCDECL(Error, _set)(NAME *m, KTYPE key, VTYPE val);
FUNCDECL(bool, _del)(NAME m, KTYPE key);
FUNCDECL(Error, _rehash)(NAME *m, size_t new_minimum_cap);
FUNCDECL(bool, _it_next)(NAME m, ITEM_TYPE **it);
FUNCDECL(bool, _it_next)(NAME m, ITEM_TYPE **restrict it);
#ifdef GENERIC_IMPL
VARDEF(const char *, __val_fmt) = NULL;
@@ -199,7 +199,7 @@ FUNCDEF(Error, _rehash)(NAME *m, size_t new_minimum_cap) {
return OK();
}
FUNCDEF(bool, _it_next)(NAME m, ITEM_TYPE **it) {
FUNCDEF(bool, _it_next)(NAME m, ITEM_TYPE **restrict it) {
*it == NULL ? *it = m.data : (*it)++;
while (*it < m.data + m.cap && (*it)->state != OCCUPIED) { (*it)++; }
return *it < m.data + m.cap;

View File

@@ -46,7 +46,7 @@ FUNCDECL(TYPE *, _get)(NAME m, const char *key);
FUNCDECL(Error, _set)(NAME *m, const char *key, TYPE val);
FUNCDECL(bool, _del)(NAME m, const char *key);
FUNCDECL(Error, _rehash)(NAME *m, size_t new_minimum_cap);
FUNCDECL(bool, _it_next)(NAME m, ITEM_TYPE **it);
FUNCDECL(bool, _it_next)(NAME m, ITEM_TYPE **restrict it);
#ifdef GENERIC_IMPL
VARDEF(const char *, __val_fmt) = NULL;
@@ -198,7 +198,7 @@ FUNCDEF(Error, _rehash)(NAME *m, size_t new_minimum_cap) {
return OK();
}
FUNCDEF(bool, _it_next)(NAME m, ITEM_TYPE **it) {
FUNCDEF(bool, _it_next)(NAME m, ITEM_TYPE **restrict it) {
*it == NULL ? *it = m.data : (*it)++;
while (*it < m.data + m.cap && (!(*it)->key || (*it)->key == TOMBSTONE)) { (*it)++; }
return *it < m.data + m.cap;