some fixes

This commit is contained in:
timerix 2022-08-26 13:58:36 +06:00
parent 2ad5790a67
commit 03b9ede382
7 changed files with 11 additions and 10 deletions

View File

@ -21,7 +21,7 @@ BUILD_TEST_CPP_ARGS="$BUILD_TEST_C_ARGS"
BUILD_TEST_LINKER_ARGS=""
# build_test_dbg
TEST_DBG_FILE=$TEST_FILE
TEST_DBG_FILE=$TEST_FILE.dbg
BUILD_TEST_DBG_C_ARGS="-O0 -g"
BUILD_TEST_DBG_CPP_ARGS="$BUILD_TEST_DBG_C_ARGS"
BUILD_TEST_DBG_LINKER_ARGS=""

View File

@ -46,6 +46,6 @@ kerepTypeId_define(kerepTypeId_AutoarrUnitypePtr);
// right func to clear array of unitype values
void __Autoarr_free_Unitype_(Autoarr(Unitype)* ar, bool freePtr){
Autoarr_foreach(ar, u,Unitype_free(u));
if(freePtr) Autoarr_free(ar, freePtr);
__Autoarr_free_Unitype(ar, freePtr);
}
void ____Autoarr_free_Unitype_(void* ar) { __Autoarr_free_Unitype_((Autoarr(Unitype)*)ar, false); }

View File

@ -29,6 +29,7 @@ typedef struct Autoarr_##type{\
} Autoarr_##type;\
\
Autoarr_##type* __Autoarr_create_##type(uint16 max_blocks_count, uint16 max_block_length);\
void __Autoarr_free_##type(Autoarr_##type* ar, bool freePtr);\
void ____Autoarr_free_##type(void* ar);
#define Autoarr(type) Autoarr_##type

View File

@ -50,7 +50,8 @@ void Hashtable_expand(Hashtable* ht){
Autoarr(KVPair)* newar=newrows[newrown];
Autoarr_add(newar,p);
}
Autoarr_free(ar, true);
// there is no need to free array values, because they are copied into new array
__Autoarr_free_KVPair(ar, true);
}
free(ht->rows);

View File

@ -17,7 +17,7 @@ void __KVPair_free(void* p){ KVPair_free(*(KVPair*)p); }
// func for KVP array clearing
void __Autoarr_free_KVPair_(Autoarr_KVPair* ar, bool freePtr){
Autoarr_foreach(ar,k,KVPair_free(k));
Autoarr_free(ar, freePtr);
__Autoarr_free_KVPair(ar, freePtr);
}
void ____Autoarr_free_KVPair_(void* ar){
__Autoarr_free_KVPair_((Autoarr_KVPair*)ar, false);

View File

@ -36,7 +36,6 @@ void __STNode_free(void* _node){
}
if(node->value.VoidPtr)
Unitype_free(node->value);
free(node);
}
void STNode_free(STNode* node){
__STNode_free(node);

View File

@ -19,17 +19,17 @@ char* sprintuni(Unitype v){
if(v.typeId==kerepTypeId_Null)
sprintf_s(buf, BUFSIZE, "{Null}");
else if(v.typeId==kerepTypeId_Float64)
sprintf_s(buf, BUFSIZE, "{%s ) %lf}", type.name,v.Float64);
sprintf_s(buf, BUFSIZE, "{%s : %lf}", type.name,v.Float64);
else if(v.typeId==kerepTypeId_Bool || v.typeId==kerepTypeId_UInt64)
sprintf_s(buf, BUFSIZE, "{%s ) " IFWIN("%llu", "%lu") "}", type.name,v.UInt64);
sprintf_s(buf, BUFSIZE, "{%s : " IFWIN("%llu", "%lu") "}", type.name,v.UInt64);
else if(v.typeId==kerepTypeId_Int64)
sprintf_s(buf, BUFSIZE, "{%s ) " IFWIN("%lld", "%ld") "}", type.name,v.Int64);
sprintf_s(buf, BUFSIZE, "{%s : " IFWIN("%lld", "%ld") "}", type.name,v.Int64);
else if(v.typeId==kerepTypeId_CharPtr){
size_t newBUFSIZE=cptr_length(v.VoidPtr) + BUFSIZE/2;
buf=realloc(buf, newBUFSIZE);
sprintf_s(buf, BUFSIZE, "{%s ) \"%s\"}", type.name,(char*)v.VoidPtr);
sprintf_s(buf, BUFSIZE, "{%s : \"%s\"}", type.name,(char*)v.VoidPtr);
}
else sprintf_s(buf, BUFSIZE, "{%s ) %p}", type.name,v.VoidPtr);
else sprintf_s(buf, BUFSIZE, "{%s : %p}", type.name,v.VoidPtr);
return buf;
}