replaced void* with unsigned char* everywhere

This commit is contained in:
2025-02-08 00:53:23 +11:00
parent 470836a390
commit c646904407
8 changed files with 17 additions and 17 deletions

View File

@@ -24,7 +24,7 @@ Toy_Bucket* Toy_allocateBucket(unsigned int capacity) {
return bucket;
}
void* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount) {
unsigned char* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount) {
//BUGFIX: the endpoint must be aligned to the word size, otherwise you'll get a bus error from moving pointers
amount = (amount + 3) & ~3;

View File

@@ -13,11 +13,11 @@ typedef struct Toy_Bucket { //32 | 64 BITNESS
struct Toy_Bucket* next; //4 | 8
unsigned int capacity; //4 | 4
unsigned int count; //4 | 4
char data[]; //- | -
unsigned char data[]; //- | -
} Toy_Bucket; //12 | 16
TOY_API Toy_Bucket* Toy_allocateBucket(unsigned int capacity);
TOY_API void* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount);
TOY_API unsigned char* Toy_partitionBucket(Toy_Bucket** bucketHandle, unsigned int amount);
TOY_API void Toy_freeBucket(Toy_Bucket** bucketHandle);
//standard capacity sizes

View File

@@ -87,7 +87,7 @@ void Toy_appendModuleBundle(Toy_ModuleBundle* bundle, Toy_Ast* ast) {
exit(-1);
}
void* module = Toy_compileModule(ast);
unsigned char* module = Toy_compileModule(ast);
//don't try writing an empty module
if (module == NULL) {

View File

@@ -30,7 +30,7 @@ static bool checkForChaining(Toy_Ast* ptr) {
}
//escapes
void* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity) {
Toy_private_EscapeArray* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity) {
//if you're freeing everything, just return
if (capacity == 0) {
free(ptr);
@@ -1035,7 +1035,7 @@ static unsigned int writeModuleCompilerCode(Toy_ModuleCompiler** mb, Toy_Ast* as
return result;
}
static void* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) {
static unsigned char* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) {
//code
writeModuleCompilerCode(&mb, ast);
@@ -1122,7 +1122,7 @@ static void* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) {
}
//exposed functions
void* Toy_compileModule(Toy_Ast* ast) {
unsigned char* Toy_compileModule(Toy_Ast* ast) {
//setup
Toy_ModuleCompiler compiler;
@@ -1153,7 +1153,7 @@ void* Toy_compileModule(Toy_Ast* ast) {
compiler.panic = false;
//compile the ast to memory
void * buffer = writeModuleCompiler(&compiler, ast);
unsigned char* buffer = writeModuleCompiler(&compiler, ast);
//cleanup
Toy_private_resizeEscapeArray(compiler.breakEscapes, 0);

View File

@@ -24,7 +24,7 @@ typedef struct Toy_private_EscapeArray {
#define TOY_ESCAPE_EXPANSION_RATE 4
#endif
TOY_API void* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity);
TOY_API Toy_private_EscapeArray* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity);
//structure for holding the module as it is built
typedef struct Toy_ModuleCompiler {
@@ -59,4 +59,4 @@ typedef struct Toy_ModuleCompiler {
bool panic;
} Toy_ModuleCompiler;
TOY_API void* Toy_compileModule(Toy_Ast* ast);
TOY_API unsigned char* Toy_compileModule(Toy_Ast* ast);

View File

@@ -51,7 +51,7 @@ static Toy_TableEntry* lookupScope(Toy_Scope* scope, Toy_String* key, unsigned i
//exposed functions
Toy_Scope* Toy_pushScope(Toy_Bucket** bucketHandle, Toy_Scope* scope) {
Toy_Scope* newScope = Toy_partitionBucket(bucketHandle, sizeof(Toy_Scope));
Toy_Scope* newScope = (Toy_Scope*)Toy_partitionBucket(bucketHandle, sizeof(Toy_Scope));
newScope->next = scope;
newScope->table = Toy_allocateTable();
@@ -73,7 +73,7 @@ Toy_Scope* Toy_popScope(Toy_Scope* scope) {
Toy_Scope* Toy_deepCopyScope(Toy_Bucket** bucketHandle, Toy_Scope* scope) {
//copy/pasted from pushScope, so I can allocate the table manually
Toy_Scope* newScope = Toy_partitionBucket(bucketHandle, sizeof(Toy_Scope));
Toy_Scope* newScope = (Toy_Scope*)Toy_partitionBucket(bucketHandle, sizeof(Toy_Scope));
newScope->next = scope->next;
newScope->table = Toy_private_adjustTableCapacity(NULL, scope->table->capacity);