From 09f158d25b3d3f33449bd9bbb76d8928d521553a Mon Sep 17 00:00:00 2001 From: jdeokkim Date: Sun, 10 Nov 2024 16:57:46 +0900 Subject: [PATCH] Update src/external/ferox_utils.h --- examples/include/ferox_raylib.h | 2 +- src/external/ferox_utils.h | 32 ++++++++++---------------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/examples/include/ferox_raylib.h b/examples/include/ferox_raylib.h index 23103fe..f63faef 100644 --- a/examples/include/ferox_raylib.h +++ b/examples/include/ferox_raylib.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2021-2023 Jaedeok Kim + Copyright (c) 2021-2024 Jaedeok Kim Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/src/external/ferox_utils.h b/src/external/ferox_utils.h index 55afea8..ad3cf81 100644 --- a/src/external/ferox_utils.h +++ b/src/external/ferox_utils.h @@ -27,41 +27,29 @@ #include #include +#include /* Macros =================================================================> */ -#define INT_BIT (sizeof(int) * CHAR_BIT) - -/* ========================================================================> */ - /* Creates a bit array with `n` bits. */ -#define frCreateBitArray(n) \ - calloc( \ - ((n) + (INT_BIT - 1)) / INT_BIT, \ - sizeof(int) \ - ) +#define frCreateBitArray(n) \ + calloc((n), sizeof(char)) /* Releases the memory allocated for `ba`. */ #define frReleaseBitArray(ba) \ free((ba)) /* Clears all bits of `ba`. */ -#define frBitArrayClear(ba, n) \ - do { \ - for (int i = 0, j = ((n) / INT_BIT); i < j; ((ba)[i] = 0), i++); \ - } while (0) +#define frBitArrayClear(ba, n) \ + memset((ba), 0, (n)) /* Returns the `i`-th bit of `ba`. */ -#define frBitArrayGet(ba, i) \ - (!!((ba)[(i) / INT_BIT] & (1 << ((i) % INT_BIT)))) +#define frBitArrayGet(ba, i) \ + ((ba)[i]) /* Sets the `i`-th bit of `ba`. */ -#define frBitArraySet(ba, i) \ - ((ba)[(i) / INT_BIT] |= (1 << ((i) % INT_BIT))) - -/* Resets the `i`-th bit of `ba`. */ -#define frBitArrayReset(ba, i) \ - ((ba)[(i) / INT_BIT] &= ~(1 << ((i) % INT_BIT))) +#define frBitArraySet(ba, i) \ + ((ba)[(i)] = 1) /* ========================================================================> */ @@ -227,6 +215,6 @@ /* Typedefs ===============================================================> */ /* A data type that represents a bit array.*/ -typedef int *frBitArray; +typedef char *frBitArray; #endif // `FEROX_UTILS_H`