Browse Source

rename some uint types to u32/u64

main
cinnaboot 5 years ago
parent
commit
6fcac783b6
  1. 12
      src/util.h

12
src/util.h

@ -4,6 +4,8 @@
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#include <cstdio>
#include <cstdlib>
#include "types.h" #include "types.h"
@ -14,7 +16,7 @@
// NOTE: FNV1a hashing algorithm http://www.isthe.com/chongo/tech/comp/fnv/ // NOTE: FNV1a hashing algorithm http://www.isthe.com/chongo/tech/comp/fnv/
#define FNV1_64_INIT ((u64) 0xcbf29ce484222325ULL) #define FNV1_64_INIT ((u64) 0xcbf29ce484222325ULL)
#define FNV_64_PRIME ((u64) 0x100000001b3ULL) #define FNV_64_PRIME ((u64) 0x100000001b3ULL)
u64 utilFNV64a_str(const char *str, u64 hval = FNV1_64_INIT); u64 utilFNV64a_str(const char* str, u64 hval = FNV1_64_INIT);
//----------------- //-----------------
// Memory allocation // Memory allocation
@ -30,7 +32,7 @@ struct MemoryArena
MemoryArena* arenaInit(size_t initial_size = DEFAULT_ARENA_SIZE); MemoryArena* arenaInit(size_t initial_size = DEFAULT_ARENA_SIZE);
void arenaFree(MemoryArena*& arena); void arenaFree(MemoryArena*& arena);
uint arenaGetFreeSize(MemoryArena* arena); u32 arenaGetFreeSize(MemoryArena* arena);
#define ARENA_ALLOC(arena, type, count) \ #define ARENA_ALLOC(arena, type, count) \
(type*) arenaAllocateBlock(arena, sizeof(type) * count) (type*) arenaAllocateBlock(arena, sizeof(type) * count)
@ -54,8 +56,8 @@ void utilSafeFree(void* p);
//----------------- //-----------------
// Hashing // Hashing
uint64_t u64
utilFNV64a_str(const char* str, uint64_t hval) utilFNV64a_str(const char* str, u64 hval)
{ {
unsigned char* s = (unsigned char *)str; // unsigned string unsigned char* s = (unsigned char *)str; // unsigned string
@ -76,7 +78,7 @@ utilFNV64a_str(const char* str, uint64_t hval)
MemoryArena* MemoryArena*
arenaInit(size_t initial_size) arenaInit(size_t initial_size)
{ {
uint sz = sizeof(MemoryArena); u32 sz = sizeof(MemoryArena);
MemoryArena* arena = MemoryArena* arena =
(MemoryArena*) std::calloc(initial_size + sz, sizeof(u8)); (MemoryArena*) std::calloc(initial_size + sz, sizeof(u8));
arena->head = arena->next_free = (uint8_t*) arena + sz; arena->head = arena->next_free = (uint8_t*) arena + sz;

Loading…
Cancel
Save