static void WowHandler_Close(TRootHandler_WoW6 * pRootHandler)
{
    if(pRootHandler != NULL)
    {
        Array_Free(&pRootHandler->FileTable);
        Array_Free(&pRootHandler->FileDataIdLookupTable);
        Map_Free(pRootHandler->pRootMap);
        CASC_FREE(pRootHandler);
    }
}
static void D3Handler_Close(TRootHandler_Diablo3 * pRootHandler)
{
    if(pRootHandler != NULL)
    {
        // Free the file map
        Map_Free(pRootHandler->pRootMap);

        // Free the array of the file entries and file names
        Array_Free(&pRootHandler->FileTable);
        Array_Free(&pRootHandler->FileNames);

        // Free the root file itself
        CASC_FREE(pRootHandler);
    }
}
Exemple #3
0
int NCDStringIndex_Init (NCDStringIndex *o)
{
    o->entries_size = 0;
    
    if (!Array_Init(o, NCDSTRINGINDEX_INITIAL_CAPACITY)) {
        BLog(BLOG_ERROR, "Array_Init failed");
        goto fail0;
    }
    
    if (!NCDStringIndex__Hash_Init(&o->hash, NCDSTRINGINDEX_INITIAL_HASH_BUCKETS)) {
        BLog(BLOG_ERROR, "NCDStringIndex__Hash_Init failed");
        goto fail1;
    }
    
    for (size_t i = 0; i < B_ARRAY_LENGTH(static_strings); i++) {
        if (do_get(o, static_strings[i], strlen(static_strings[i])) < 0) {
            goto fail2;
        }
    }
    
    DebugObject_Init(&o->d_obj);
    return 1;
    
fail2:
    for (NCD_string_id_t i = 0; i < o->entries_size; i++) {
        free(o->entries[i].str);
    }
    NCDStringIndex__Hash_Free(&o->hash);
fail1:
    Array_Free(o);
fail0:
    return 0;
}
Exemple #4
0
void StringChunk_Free(StringChunk *dl)
{
	StringList_Free(&(dl -> List));
	HashTable_Free(&(dl -> List_Pos));
	StringList_Free(&(dl -> List_W));
	Array_Free(&(dl -> List_W_Pos));
	ExtendableBuffer_Free(&(dl -> AdditionalDataChunk));
}
Exemple #5
0
void NCDStringIndex_Free (NCDStringIndex *o)
{
    DebugObject_Free(&o->d_obj);
    
    for (NCD_string_id_t i = 0; i < o->entries_size; i++) {
        free(o->entries[i].str);
    }
    
    NCDStringIndex__Hash_Free(&o->hash);
    Array_Free(o);
}
Exemple #6
0
/*
    Fonction Array_Free
    Paramètre array : Pointeur sur tableau à libérer
    Paramètre n_dim : Nombre de dimensions du tableau
    Libère la mémoire allouée d'un tableau de n'importe quel type primaire à n_dim dimensions
*/
void Array_Free(void * array,int n_dim)
{
	if(!array) { fprintf(stderr,"Array_Free : Cannot free NULL pointer. Abort.\n");	return; }
	if(n_dim>1)
	{
		int i=0;
		size_t size = sizeof(void *);
		while(*(void**)(array + i*size) )
			Array_Free(*(void**)(array+i++*size), n_dim-1);
	}
	free(array);
}
Exemple #7
0
int StringChunk_Init(StringChunk *dl, int InitialCount /* For no-wildcard domain */)
{
	if( StringList_Init(&(dl -> List), NULL, 0) != 0 )
	{
		return -1;
	}

	if( HashTable_Init(&(dl -> List_Pos), sizeof(EntryForString), InitialCount, NULL) != 0 )
	{
		StringList_Free(&(dl -> List));
		return -2;
	}

	if( StringList_Init(&(dl -> List_W), NULL, 0) != 0 )
	{
		StringList_Free(&(dl -> List));
		HashTable_Free(&(dl -> List_Pos));
		return -3;
	}

	if( Array_Init(&(dl -> List_W_Pos), sizeof(EntryForString), 0, FALSE, NULL) != 0 )
	{
		StringList_Free(&(dl -> List));
		HashTable_Free(&(dl -> List_Pos));
		StringList_Free(&(dl -> List_W));
		return -4;
	}

	if( ExtendableBuffer_Init(&(dl -> AdditionalDataChunk), 0, -1) != 0 )
	{
		StringList_Free(&(dl -> List));
		HashTable_Free(&(dl -> List_Pos));
		StringList_Free(&(dl -> List_W));
		Array_Free(&(dl -> List_W_Pos));
		return -5;
	}

	return 0;
}
int testArray() {
  Array arr;
  Array_Init(&arr);
  ASSERT_EQUAL(0, arr.capacity);
  ASSERT_EQUAL(0, arr.len);
  ASSERT(arr.data == NULL);

  void *p = Array_Add(&arr, 2);
  ASSERT_EQUAL(16, arr.capacity);
  ASSERT_EQUAL(2, arr.len);
  ASSERT(p == arr.data);

  p = Array_Add(&arr, 20);
  ASSERT_EQUAL(32, arr.capacity);
  ASSERT_EQUAL(22, arr.len);
  ASSERT((char *)p == arr.data + 2);

  Array_ShrinkToSize(&arr);
  ASSERT_EQUAL(22, arr.capacity);

  Array_Free(&arr);
  return 0;
}
Exemple #9
0
void CacheHT_Free(CacheHT *h)
{
	Array_Free(&(h -> NodeChunk));
	Array_Free(&(h -> Slots));
	h -> FreeList = -1;
}
Exemple #10
0
void Stack_Uninitialize(Stack* self) {
	Array_Free(&self->Data);
	self->Pointer = 0;
}