From 51a7412af3d495e40f1e3a3e42df80b8f723544f Mon Sep 17 00:00:00 2001 From: snit Date: Sun, 29 Sep 2024 02:33:16 -0500 Subject: [PATCH] more standard const qualifiers --- src/entity/registry.c | 6 +++--- src/entity/registry.h | 6 +++--- src/error.c | 2 +- src/error.h | 2 +- src/render/render.c | 6 +++--- src/render/render.h | 2 +- src/world.c | 4 ++-- src/world.h | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/entity/registry.c b/src/entity/registry.c index b0482ea..fb3e792 100644 --- a/src/entity/registry.c +++ b/src/entity/registry.c @@ -9,13 +9,13 @@ enum error_t entity_registrant_init( struct entity_registrant_t *self, - const char *name, char tile + char const *name, char tile ) { assert(self != NULL); if (name == NULL || strlen(name) > MAX_NAME_LENGTH) return ERR_INPUT; - const char *dup = strndup(name, MAX_NAME_LENGTH); + char const *dup = strndup(name, MAX_NAME_LENGTH); if (dup == NULL) return ERR_ALLOC; self->name = dup; @@ -57,7 +57,7 @@ void entity_registry_free(struct entity_registry_t *self) { enum error_t entity_registry_append( struct entity_registry_t *self, - struct entity_registrant_t *registrant + struct entity_registrant_t const *registrant ) { assert(self != NULL && registrant != NULL); diff --git a/src/entity/registry.h b/src/entity/registry.h index 9cadf8b..9540d76 100644 --- a/src/entity/registry.h +++ b/src/entity/registry.h @@ -6,13 +6,13 @@ #include "../error.h" struct entity_registrant_t { - const char *name; + char const *name; char tile; }; enum error_t entity_registrant_init( struct entity_registrant_t *, - const char *, char + char const *, char ); void entity_registrant_free(struct entity_registrant_t *); @@ -28,7 +28,7 @@ void entity_registry_free(struct entity_registry_t *); enum error_t entity_registry_append( struct entity_registry_t *, - struct entity_registrant_t * + struct entity_registrant_t const * ); #endif diff --git a/src/error.c b/src/error.c index 9222cf2..864dae0 100644 --- a/src/error.c +++ b/src/error.c @@ -2,7 +2,7 @@ #include "error.h" -const char *const ERROR_STRS[] = { +char const *const ERROR_STRS[] = { "SUCCESS", "BAD INPUT", "ALLOCATION", diff --git a/src/error.h b/src/error.h index 303c22e..bf9ee1f 100644 --- a/src/error.h +++ b/src/error.h @@ -9,6 +9,6 @@ enum error_t { __ERR_COUNT, }; -extern const char *const ERROR_STRS[]; +extern char const *const ERROR_STRS[]; #endif diff --git a/src/render/render.c b/src/render/render.c index cee5040..70a8692 100644 --- a/src/render/render.c +++ b/src/render/render.c @@ -4,10 +4,10 @@ #include "render.h" -void render_world(struct world_t *world) { +void render_world(struct world_t const *world) { for (size_t i = 0; i < MAX_ENTITIES; i++) { - struct entity_t *entity = &world->entities[i]; - struct entity_registrant_t *registrant = + struct entity_t const *const entity = &world->entities[i]; + struct entity_registrant_t const *const registrant = &world->registered_entities.entities[entity->id]; if (entity->id == 0) continue; diff --git a/src/render/render.h b/src/render/render.h index b5fc970..57e638e 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -3,6 +3,6 @@ #include "../world.h" -void render_world(struct world_t *); +void render_world(struct world_t const *); #endif diff --git a/src/world.c b/src/world.c index 7f44790..5bea6f8 100644 --- a/src/world.c +++ b/src/world.c @@ -38,7 +38,7 @@ void world_free(struct world_t *self) { enum error_t world_register_entity( struct world_t *self, - const char *name, char tile + char const *name, char tile ) { enum error_t err; struct entity_registry_t *registry = &self->registered_entities; @@ -53,7 +53,7 @@ enum error_t world_register_entity( return ERR_OK; } -static size_t world_find_empty_entity(struct world_t *self) { +static size_t world_find_empty_entity(struct world_t const *self) { for (size_t i = 0; i < MAX_ENTITIES; i++) if (self->entities[i].id == 0) return i; diff --git a/src/world.h b/src/world.h index c1df4c1..5d9678c 100644 --- a/src/world.h +++ b/src/world.h @@ -20,7 +20,7 @@ struct world_t { enum error_t world_init(struct world_t *, size_t, size_t); void world_free(struct world_t *); -enum error_t world_register_entity(struct world_t *, const char *, char); +enum error_t world_register_entity(struct world_t *, char const *, char); enum error_t world_place_entity(struct world_t *, size_t, size_t, size_t); #endif