void ArrayList_Free(wArrayList* arrayList) { ArrayList_Clear(arrayList); CloseHandle(arrayList->mutex); free(arrayList->array); free(arrayList); }
void _tsmf_presentation_free(TSMF_PRESENTATION* presentation) { tsmf_presentation_stop(presentation); ArrayList_Clear(presentation->stream_list); ArrayList_Free(presentation->stream_list); free(presentation->rects); ZeroMemory(presentation, sizeof(TSMF_PRESENTATION)); free(presentation); }
void _tsmf_presentation_free(TSMF_PRESENTATION *presentation) { tsmf_presentation_stop(presentation); ArrayList_Clear(presentation->stream_list); ArrayList_Free(presentation->stream_list); if (presentation->rects) free(presentation->rects); memset(presentation, 0, sizeof(TSMF_PRESENTATION)); free(presentation); }
void rpc_free(rdpRpc* rpc) { if (rpc != NULL) { rpc_client_stop(rpc); if (rpc->State >= RPC_CLIENT_STATE_CONTEXT_NEGOTIATED) { ntlm_client_uninit(rpc->ntlm); ntlm_free(rpc->ntlm); } rpc_client_virtual_connection_free(rpc->VirtualConnection); ArrayList_Clear(rpc->VirtualConnectionCookieTable); ArrayList_Free(rpc->VirtualConnectionCookieTable); free(rpc); } }
void HeapList_FreeAll(HeapList_T * list) { size_t i, k, count; byte_t * loop; HeapList_Block_T * block_list; ArrayList_Clear(&list->unused_memory); block_list = ArrayList_Get(&list->block_list, &count, NULL); for(i = 0; i < count; i++) { loop = block_list[i].memory; for(k = 0; k < block_list[i].size; k++) { ArrayList_CopyAdd(&list->unused_memory, &loop, NULL); loop = loop + list->element_size; } } list->count = 0; }
int TestArrayList(int argc, char* argv[]) { int index; int count; size_t val; wArrayList* arrayList; const int elemsToInsert = 10; arrayList = ArrayList_New(TRUE); if (!arrayList) return -1; for (index = 0; index < elemsToInsert; index++) { if (ArrayList_Add(arrayList, (void*) (size_t) index) < 0) return -1; } count = ArrayList_Count(arrayList); printf("ArrayList count: %d\n", count); index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1); printf("ArrayList index: %d\n", index); if (index != 6) return -1; ArrayList_Insert(arrayList, 5, (void*) (size_t) 100); index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1); printf("ArrayList index: %d\n", index); if (index != 7) return -1; ArrayList_Remove(arrayList, (void*) (size_t) 100); index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1); printf("ArrayList index: %d\n", index); if (index != 6) return -1; for (index = 0; index < elemsToInsert; index++) { val = (size_t)ArrayList_GetItem(arrayList, 0); ArrayList_RemoveAt(arrayList, 0); if (val != index) { printf("ArrayList: shifted %d entries, expected value %d, got %"PRIdz"\n", index, index, val); return -1; } } index = ArrayList_IndexOf(arrayList, (void*) (size_t) elemsToInsert, -1, -1); printf("ArrayList index: %d\n", index); if (index != -1) return -1; count = ArrayList_Count(arrayList); printf("ArrayList count: %d\n", count); if (count != 0) return -1; ArrayList_Clear(arrayList); ArrayList_Free(arrayList); return 0; }