From a93af5c48f4e70f8f5be571fbdb91c84e898d0eb Mon Sep 17 00:00:00 2001 From: Zy Date: Sat, 12 Oct 2024 22:33:06 +0200 Subject: [PATCH] dev: norm --- dev/norm.sh | 10 +++++----- include/mlx3ds_embeddedassets.h | 16 ++++++++-------- source/mlx3ds_embeddedassets.c | 19 +++++++++++-------- source/mlx_internal.h | 4 ++-- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/dev/norm.sh b/dev/norm.sh index 95e39dd..946a790 100755 --- a/dev/norm.sh +++ b/dev/norm.sh @@ -2,7 +2,7 @@ # Use the norminette but without all these rules that make coding harder. -norminette | grep -v \ +norminette $* | grep -v \ "INVALID_HEADER VAR_DECL_START_FUNC EMPTY_LINE_FUNCTION @@ -10,10 +10,10 @@ TOO_MANY_ARGS TOO_MANY_FUNCS TOO_MANY_LINES PREPROC_CONSTANT -MACRO_FUNC_FORBIDDEN GLOBAL_VAR_DETECTED WRONG_SCOPE_COMMENT MULT_DECL_LINE -GOTO_FBIDDEN -LABEL_FBIDDEN -TERNARY_FBIDDEN" +FORBIDDEN +FBIDDEN +SPACE_EMPTY_LINE +DECL_ASSIGN_LINE" diff --git a/include/mlx3ds_embeddedassets.h b/include/mlx3ds_embeddedassets.h index b83dcdb..8397f85 100644 --- a/include/mlx3ds_embeddedassets.h +++ b/include/mlx3ds_embeddedassets.h @@ -10,8 +10,8 @@ * with embedassets.sh. */ -#ifndef MLX3DS_ASSETS_H -# define MLX3DS_ASSETS_H +#ifndef MLX3DS_EMBEDDEDASSETS_H +# define MLX3DS_EMBEDDEDASSETS_H # include @@ -21,12 +21,12 @@ typedef void *t_assetsocket; /// @brief Represents a file embedded with the program. typedef struct s_embeddedasset { - /// @brief Path of the file, relative to the assets directory (`.+(/.+)+`). - const char *name; - /// @brief Size of the file content. - size_t size; - /// @brief Content of the file. NUL-terminated (data[size] is '\0'). - const char *data; + /// @brief Path of the file, relative to the assets directory (`.+(/.+)+`). + const char *name; + /// @brief Size of the file content. + size_t size; + /// @brief Content of the file. NUL-terminated (data[size] is '\0'). + const char *data; } t_embeddedasset; /// @brief Get an reference to the t_embeddedasset from its name. diff --git a/source/mlx3ds_embeddedassets.c b/source/mlx3ds_embeddedassets.c index 5720007..9a66f69 100644 --- a/source/mlx3ds_embeddedassets.c +++ b/source/mlx3ds_embeddedassets.c @@ -21,32 +21,35 @@ typedef struct s_in_assetsocket // This function is implemented in embedassets.sh const t_embeddedasset *mlx3ds_assets_get(const char *name); -t_assetsocket mlx3ds_assets_open(const char *name) { +t_assetsocket mlx3ds_assets_open(const char *name) +{ const t_embeddedasset *asset; t_in_assetsocket *r; asset = mlx3ds_assets_get(name); if (!asset) - return NULL; + return (NULL); r = malloc(sizeof(t_in_assetsocket)); if (!r) - return NULL; + return (NULL); r->asset = asset; r->i = 0; - return r; + return (r); } -size_t mlx3ds_assets_read(t_assetsocket asset, void *buf, size_t count) { - t_in_assetsocket *asset_ = asset; +size_t mlx3ds_assets_read(t_assetsocket asset, void *buf, size_t count) +{ + t_in_assetsocket *asset_ = asset; if (count > asset_->asset->size - asset_->i) count = asset_->asset->size - asset_->i; memcpy(buf, asset_->asset->data + asset_->i, count); asset_->i += count; - return count; + return (count); } -void mlx3ds_assets_close(t_assetsocket asset) { +void mlx3ds_assets_close(t_assetsocket asset) +{ free(asset); } diff --git a/source/mlx_internal.h b/source/mlx_internal.h index cc456f4..4627a8a 100644 --- a/source/mlx_internal.h +++ b/source/mlx_internal.h @@ -20,13 +20,13 @@ /// @param msg Message to write. Must use less than 38 colons. void mlx3ds_internal_fatalerror(const char *msg); -struct s_internal_win; +struct s_internal_win; /// @brief Content of the mlx connection identifier. typedef struct s_internal_mlx { /// @brief is true after mlx_init() was called, is false before. - bool is_init_called; + bool is_init_called; /// @brief Window displayed on the top screen. struct s_internal_win *top_window; } t_internal_mlx;