fixed Array marcos
This commit is contained in:
parent
921bada09a
commit
f7b0b53d05
@ -7,12 +7,12 @@ typedef struct Array {
|
|||||||
} Array;
|
} Array;
|
||||||
|
|
||||||
/// creates Array from a const array
|
/// creates Array from a const array
|
||||||
#define Array_CONST(T, A...) Array_construct_size(((T[])A), sizeof((T[])A))
|
#define ARRAY(T, A...) Array_construct_size(((T[])A), sizeof((T[])A))
|
||||||
|
|
||||||
#define Array_construct(DATA, T, COUNT) Array_construct_size(DATA, (COUNT) * sizeof(T))
|
#define Array_construct(DATA, T, COUNT) Array_construct_size(DATA, (COUNT) * sizeof(T))
|
||||||
#define Array_construct_size(DATA, LEN) ((Array){ .data = (DATA), .size = (LEN) })
|
#define Array_construct_size(DATA, LEN) ((Array){ .data = (DATA), .size = (LEN) })
|
||||||
|
|
||||||
#define Array_alloc(T, COUNT) Array_alloc((COUNT) * sizeof(T))
|
#define Array_alloc(T, COUNT) Array_alloc_size((COUNT) * sizeof(T))
|
||||||
|
|
||||||
static inline Array Array_alloc_size(u32 size){
|
static inline Array Array_alloc_size(u32 size){
|
||||||
return Array_construct_size(malloc(size), size);
|
return Array_construct_size(malloc(size), size);
|
||||||
@ -25,4 +25,5 @@ static inline void Array_realloc_size(Array* ar, u32 new_size){
|
|||||||
ar->size = new_size;
|
ar->size = new_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Array_len(AR, T) ((AR)->size / sizeof(T))
|
#define Array_len(AR, T) ((AR)->size / sizeof(T))
|
||||||
|
#define Array_memset(A, VAL) memset((A)->data, VAL, (A)->size)
|
||||||
@ -6,7 +6,7 @@
|
|||||||
#define __HashMap_HASH_FUNC str_hash32
|
#define __HashMap_HASH_FUNC str_hash32
|
||||||
#define __HashMapBucket_MAX_LEN 16
|
#define __HashMapBucket_MAX_LEN 16
|
||||||
|
|
||||||
static const Array __HashMap_heights = Array_CONST(u32, {
|
static const Array __HashMap_heights = ARRAY(u32, {
|
||||||
17, 31, 61, 127, 257, 521, 1021, 2053, 4099, 8191, 16381, 32771,
|
17, 31, 61, 127, 257, 521, 1021, 2053, 4099, 8191, 16381, 32771,
|
||||||
65521, 131071, 262147, 524287, 1048583, 2097169, 4194319,
|
65521, 131071, 262147, 524287, 1048583, 2097169, 4194319,
|
||||||
8388617, 16777213, 33554467, 67108859, 134217757, 268435493
|
8388617, 16777213, 33554467, 67108859, 134217757, 268435493
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user