registred all types

This commit is contained in:
2022-08-25 01:37:14 +06:00
parent 2e378d1458
commit d62405ccff
24 changed files with 201 additions and 213 deletions

View File

@@ -17,10 +17,14 @@ Hashtable* Hashtable_create(){
return ht;
}
void Hashtable_free(Hashtable* ht){
void __Hashtable_free(void* _ht){
Hashtable* ht=_ht;
for(uint16 i=0;i<HT_HEIGHTS[ht->hein];i++)
Autoarr_free_KVPair(ht->rows[i]);
Autoarr_free(ht->rows[i], true);
free(ht->rows);
}
void Hashtable_free(Hashtable* ht){
__Hashtable_free(ht);
free(ht);
}
@@ -43,7 +47,7 @@ void Hashtable_expand(Hashtable* ht){
Autoarr(KVPair)* newar=newrows[newrown];
Autoarr_add(newar,p);
}
Autoarr_free(ar);
Autoarr_free(ar, true);
}
free(ht->rows);

View File

@@ -16,6 +16,7 @@ kerepType_declare(HashtablePtr);
Hashtable* Hashtable_create();
void Hashtable_free(Hashtable* ht);
void __Hashtable_free(void* ht);
// amount of rows
uint16 Hashtable_height(Hashtable* ht);

View File

@@ -8,11 +8,15 @@ void KVPair_free(KVPair p){
free(p.key);
Unitype_free(p.value);
}
void __KVPair_free(void* p){ KVPair_free(*(KVPair*)p); }
// func for KVP array clearing
void Autoarr_free_KVPair(Autoarr_KVPair* ar){
void __Autoarr_free_KVPair_(Autoarr_KVPair* ar, bool freePtr){
Autoarr_foreach(ar,k,KVPair_free(k));
Autoarr_free(ar);
Autoarr_free(ar, freePtr);
}
void ____Autoarr_free_KVPair_(void* ar){
__Autoarr_free_KVPair_((Autoarr_KVPair*)ar, false);
}
void printkvp(KVPair p){

View File

@@ -11,14 +11,20 @@ typedef struct KVPair{
char* key;
Unitype value;
} KVPair;
kerepType_declare(KVPair);
kerepType_declare(KVPairPtr);
Autoarr_declare(KVPair)
kerepType_declare(AutoarrKVPair);
kerepType_declare(AutoarrKVPairPtr);
// proper way to clear a KVP
void KVPair_free(KVPair p);
void __KVPair_free(void* p);
// func to clear KVP array
void Autoarr_free_KVPair(Autoarr_KVPair* ar);
void __Autoarr_free_KVPair_(Autoarr_KVPair* ar, bool freePtr);
void ____Autoarr_free_KVPair_(void* ar);
void printkvp(KVPair p);