spritesheet being read in, needs testing and possible memory leak fix

This commit is contained in:
herbglitch 2025-03-26 04:27:02 -06:00
parent 15ee2819b1
commit 2e97d908d8
7 changed files with 120 additions and 202 deletions

View file

@ -364,6 +364,8 @@ void ARC_ConfigData_RunVariableLineTag(ARC_ParserTagToken *tagToken, ARC_Config
}
removingType->destroyFn = ARC_ConfigType_EmptyDestroyFn;
free(array->data);
free(array);
ARC_Hashtable_Remove(config->currentGroup, (void *)variableString->data);
return;
}
@ -428,7 +430,7 @@ void ARC_ConfigData_RunVariableLineTag(ARC_ParserTagToken *tagToken, ARC_Config
//create a temporary vector to read in the array
ARC_VectorInline *typeVector;
ARC_VectorInline_Create(&typeVector, sizeof(void *), NULL, NULL);
ARC_VectorInline_Create(&typeVector, type->size, NULL, NULL);
//<valueArgs> -> <value> <whitespace> COMMA <whitespace> <valueArgs> | <value>
while(valueArgsTagToken->id == ARC_CONFIG_VALUE_ARGS){
@ -456,8 +458,8 @@ void ARC_ConfigData_RunVariableLineTag(ARC_ParserTagToken *tagToken, ARC_Config
if(typeVectorArray.size != 0){
//copy the vector into the array's data
array->data = (void **)malloc(sizeof(void *) * typeVectorArray.size);
memcpy(array->data, typeVectorArray.data, typeVectorArray.size);
array->data = (void *)malloc(type->size * typeVectorArray.size);
memcpy(array->data, typeVectorArray.data, type->size * typeVectorArray.size);
}
//set the type data as an array
@ -885,6 +887,8 @@ void ARC_Config_Remove(ARC_Config *config, ARC_String *name, ARC_Bool isArray){
}
typeData->destroyFn = ARC_ConfigType_EmptyDestroyFn;
free(array);
}
//remove the value
@ -1042,18 +1046,18 @@ void ARC_Config_UnloadFromFile(ARC_Config *config, ARC_String *path){
}
void ARC_Config_InitStd(ARC_Config *config){
ARC_Config_RegisterTypeWithCStr(config, "bool" , (ARC_ConfigType){ ARC_ConfigType_BoolCopyFn , ARC_ConfigType_BoolDestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "int8" , (ARC_ConfigType){ ARC_ConfigType_Int8CopyFn , ARC_ConfigType_Int8DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "uint8" , (ARC_ConfigType){ ARC_ConfigType_Uint8CopyFn , ARC_ConfigType_Uint8DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "int16" , (ARC_ConfigType){ ARC_ConfigType_Int16CopyFn , ARC_ConfigType_Int16DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "uint16" , (ARC_ConfigType){ ARC_ConfigType_Uint16CopyFn, ARC_ConfigType_Uint16DestroyFn, NULL });
ARC_Config_RegisterTypeWithCStr(config, "int32" , (ARC_ConfigType){ ARC_ConfigType_Int32CopyFn , ARC_ConfigType_Int32DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "uint32" , (ARC_ConfigType){ ARC_ConfigType_Uint32CopyFn, ARC_ConfigType_Uint32DestroyFn, NULL });
ARC_Config_RegisterTypeWithCStr(config, "int64" , (ARC_ConfigType){ ARC_ConfigType_Int64CopyFn , ARC_ConfigType_Int64DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "uint64" , (ARC_ConfigType){ ARC_ConfigType_Uint64CopyFn, ARC_ConfigType_Uint64DestroyFn, NULL });
ARC_Config_RegisterTypeWithCStr(config, "float" , (ARC_ConfigType){ ARC_ConfigType_FloatCopyFn , ARC_ConfigType_FloatDestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "double" , (ARC_ConfigType){ ARC_ConfigType_DoubleCopyFn, ARC_ConfigType_DoubleDestroyFn, NULL });
ARC_Config_RegisterTypeWithCStr(config, "ARC_String", (ARC_ConfigType){ ARC_ConfigType_StringCopyFn, ARC_ConfigType_StringDestroyFn, NULL });
ARC_Config_RegisterTypeWithCStr(config, "bool" , (ARC_ConfigType){ sizeof(ARC_Bool) , ARC_ConfigType_BoolCopyFn , ARC_ConfigType_BoolDestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "int8" , (ARC_ConfigType){ sizeof(int8_t) , ARC_ConfigType_Int8CopyFn , ARC_ConfigType_Int8DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "uint8" , (ARC_ConfigType){ sizeof(uint8_t) , ARC_ConfigType_Uint8CopyFn , ARC_ConfigType_Uint8DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "int16" , (ARC_ConfigType){ sizeof(int16_t) , ARC_ConfigType_Int16CopyFn , ARC_ConfigType_Int16DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "uint16" , (ARC_ConfigType){ sizeof(uint16_t) , ARC_ConfigType_Uint16CopyFn, ARC_ConfigType_Uint16DestroyFn, NULL });
ARC_Config_RegisterTypeWithCStr(config, "int32" , (ARC_ConfigType){ sizeof(int32_t) , ARC_ConfigType_Int32CopyFn , ARC_ConfigType_Int32DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "uint32" , (ARC_ConfigType){ sizeof(uint32_t) , ARC_ConfigType_Uint32CopyFn, ARC_ConfigType_Uint32DestroyFn, NULL });
ARC_Config_RegisterTypeWithCStr(config, "int64" , (ARC_ConfigType){ sizeof(int64_t) , ARC_ConfigType_Int64CopyFn , ARC_ConfigType_Int64DestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "uint64" , (ARC_ConfigType){ sizeof(uint64_t) , ARC_ConfigType_Uint64CopyFn, ARC_ConfigType_Uint64DestroyFn, NULL });
ARC_Config_RegisterTypeWithCStr(config, "float" , (ARC_ConfigType){ sizeof(float) , ARC_ConfigType_FloatCopyFn , ARC_ConfigType_FloatDestroyFn , NULL });
ARC_Config_RegisterTypeWithCStr(config, "double" , (ARC_ConfigType){ sizeof(double) , ARC_ConfigType_DoubleCopyFn, ARC_ConfigType_DoubleDestroyFn, NULL });
ARC_Config_RegisterTypeWithCStr(config, "ARC_String", (ARC_ConfigType){ sizeof(ARC_String), ARC_ConfigType_StringCopyFn, ARC_ConfigType_StringDestroyFn, NULL });
}
void ARC_ConfigType_BoolCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata){