Skip to content

Commit

Permalink
Update src/external/ferox_utils.h
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeokkim committed Nov 10, 2024
1 parent 48d34b0 commit 09f158d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/include/ferox_raylib.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2021-2023 Jaedeok Kim <[email protected]>
Copyright (c) 2021-2024 Jaedeok Kim <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand Down
32 changes: 10 additions & 22 deletions src/external/ferox_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,29 @@

#include <limits.h>
#include <stdlib.h>
#include <string.h>

/* 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)

/* ========================================================================> */

Expand Down Expand Up @@ -227,6 +215,6 @@
/* Typedefs ===============================================================> */

/* A data type that represents a bit array.*/
typedef int *frBitArray;
typedef char *frBitArray;

#endif // `FEROX_UTILS_H`

0 comments on commit 09f158d

Please sign in to comment.