static void GuestInfoDestroyCollector(GuestInfoCollector *collector) // IN: { if (collector != NULL) { HashTable_Free(collector->exactMatches); HashTable_Free(collector->reportMap); free(collector->regExps); free(collector->stats); free(collector); } }
static void MsgCatalogFree(MsgCatalog *catalog) { ASSERT(catalog); #if defined(_WIN32) if (catalog->utf16 != NULL) { HashTable_Free(catalog->utf16); } #endif if (catalog->utf8 != NULL) { HashTable_Free(catalog->utf8); } g_free(catalog); }
void wf_rail_uninit(wfContext* wfc, RailClientContext* rail) { wfc->rail = NULL; rail->custom = NULL; HashTable_Free(wfc->railWindows); }
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)); }
static int rdpgfx_plugin_terminated(IWTSPlugin* pPlugin) { int count; int index; ULONG_PTR* pKeys = NULL; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) pPlugin; RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface; WLog_Print(gfx->log, WLOG_DEBUG, "Terminated"); if (gfx->listener_callback) free(gfx->listener_callback); zgfx_context_free(gfx->zgfx); count = HashTable_GetKeys(gfx->SurfaceTable, &pKeys); for (index = 0; index < count; index++) { RDPGFX_DELETE_SURFACE_PDU pdu; pdu.surfaceId = ((UINT16) pKeys[index]) - 1; if (context && context->DeleteSurface) { context->DeleteSurface(context, &pdu); } } free(pKeys); HashTable_Free(gfx->SurfaceTable); for (index = 0; index < gfx->MaxCacheSlot; index++) { if (gfx->CacheSlots[index]) { RDPGFX_EVICT_CACHE_ENTRY_PDU pdu; pdu.cacheSlot = (UINT16) index; if (context && context->EvictCacheEntry) { context->EvictCacheEntry(context, &pdu); } gfx->CacheSlots[index] = NULL; } } free(context); free(gfx); return 0; }
void VMToolsMsgCleanup(void) { if (gMsgState != NULL) { if (gMsgState->domains != NULL) { HashTable_Free(gMsgState->domains); } g_static_mutex_free(&gMsgState->lock); g_free(gMsgState); } }
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 xf_rail_uninit(xfContext* xfc, RailClientContext* rail) { if (xfc->rail) { xfc->rail->custom = NULL; xfc->rail = NULL; } if (xfc->railWindows) { HashTable_Free(xfc->railWindows); xfc->railWindows = NULL; } return 1; }
void freerdp_channels_free(rdpChannels* channels) { int index; int nkeys; ULONG_PTR* pKeys = NULL; CHANNEL_OPEN_DATA* pChannelOpenData; if (!channels) return; if (channels->queue) { MessageQueue_Free(channels->queue); channels->queue = NULL; } for (index = 0; index < channels->clientDataCount; index++) { pChannelOpenData = &channels->openDataList[index]; if (pChannelOpenData->pInterface) { free(pChannelOpenData->pInterface); pChannelOpenData->pInterface = NULL; } HashTable_Remove(g_OpenHandles, (void*) (UINT_PTR)pChannelOpenData->OpenHandle); } if (g_OpenHandles) { nkeys = HashTable_GetKeys(g_OpenHandles, &pKeys); if (nkeys == 0) { HashTable_Free(g_OpenHandles); DeleteCriticalSection(&g_channels_lock); g_OpenHandles = NULL; } free(pKeys); } free(channels); }
void freerdp_channels_free(rdpChannels* channels) { if (!channels) return; DeleteCriticalSection(&channels->channelsLock); if (channels->queue) { MessageQueue_Free(channels->queue); channels->queue = NULL; } if (channels->openHandles) HashTable_Free(channels->openHandles); free(channels); }
void freerdp_channels_free(rdpChannels* channels) { int index; CHANNEL_OPEN_DATA* pChannelOpenData; if (!channels) return; DeleteCriticalSection(&channels->channelsLock); if (channels->queue) { MessageQueue_Free(channels->queue); channels->queue = NULL; } for (index = 0; index < channels->clientDataCount; index++) { pChannelOpenData = &channels->openDataList[index]; if (pChannelOpenData->pInterface) { free(pChannelOpenData->pInterface); pChannelOpenData->pInterface = NULL; } freerdp_channel_remove_open_handle_data(&g_ChannelHandles, pChannelOpenData->OpenHandle); if (channels->openHandles) HashTable_Remove(channels->openHandles, (void*)(UINT_PTR)pChannelOpenData->OpenHandle); } if (channels->openHandles) HashTable_Free(channels->openHandles); free(channels); }
int test_hash_table_string() { int count; char* value; wHashTable* table; table = HashTable_New(TRUE); if (!table) return -1; table->hash = HashTable_StringHash; table->keyCompare = HashTable_StringCompare; table->valueCompare = HashTable_StringCompare; table->keyClone = HashTable_StringClone; table->valueClone = HashTable_StringClone; table->keyFree = HashTable_StringFree; table->valueFree = HashTable_StringFree; HashTable_Add(table, key1, val1); HashTable_Add(table, key2, val2); HashTable_Add(table, key3, val3); count = HashTable_Count(table); if (count != 3) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 3, count); return -1; } HashTable_Remove(table, key2); count = HashTable_Count(table); if (count != 2) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 2, count); return -1; } HashTable_Remove(table, key3); count = HashTable_Count(table); if (count != 1) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 1, count); return -1; } HashTable_Remove(table, key1); count = HashTable_Count(table); if (count != 0) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 0, count); return -1; } HashTable_Add(table, key1, val1); HashTable_Add(table, key2, val2); HashTable_Add(table, key3, val3); count = HashTable_Count(table); if (count != 3) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 3, count); return -1; } value = (char*) HashTable_GetItemValue(table, key1); if (strcmp(value, val1) != 0) { printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", val1, value); return -1; } value = (char*) HashTable_GetItemValue(table, key2); if (strcmp(value, val2) != 0) { printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", val2, value); return -1; } value = (char*) HashTable_GetItemValue(table, key3); if (strcmp(value, val3) != 0) { printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", val3, value); return -1; } HashTable_SetItemValue(table, key2, "apple"); value = (char*) HashTable_GetItemValue(table, key2); if (strcmp(value, "apple") != 0) { printf("HashTable_GetItemValue: Expected : %s, Actual: %s\n", "apple", value); return -1; } if (!HashTable_Contains(table, key2)) { printf("HashTable_Contains: Expected : %d, Actual: %d\n", TRUE, FALSE); return -1; } if (!HashTable_Remove(table, key2)) { printf("HashTable_Remove: Expected : %d, Actual: %d\n", TRUE, FALSE); return -1; } if (HashTable_Remove(table, key2)) { printf("HashTable_Remove: Expected : %d, Actual: %d\n", FALSE, TRUE); return -1; } HashTable_Clear(table); count = HashTable_Count(table); if (count != 0) { printf("HashTable_Count: Expected : %d, Actual: %d\n", 0, count); return -1; } HashTable_Free(table); return 1; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ static UINT rdpgfx_plugin_terminated(IWTSPlugin* pPlugin) { int count; int index; ULONG_PTR* pKeys = NULL; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) pPlugin; RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface; UINT error = CHANNEL_RC_OK; WLog_Print(gfx->log, WLOG_DEBUG, "Terminated"); if (gfx->listener_callback) { free(gfx->listener_callback); gfx->listener_callback = NULL; } if (gfx->zgfx) { zgfx_context_free(gfx->zgfx); gfx->zgfx = NULL; } count = HashTable_GetKeys(gfx->SurfaceTable, &pKeys); for (index = 0; index < count; index++) { RDPGFX_DELETE_SURFACE_PDU pdu; pdu.surfaceId = ((UINT16) pKeys[index]) - 1; if (context) { IFCALLRET(context->DeleteSurface, error, context, &pdu); if (error) { WLog_Print(gfx->log, WLOG_ERROR, "context->DeleteSurface failed with error %"PRIu32"", error); free(pKeys); free(context); free(gfx); return error; } } } free(pKeys); HashTable_Free(gfx->SurfaceTable); for (index = 0; index < gfx->MaxCacheSlot; index++) { if (gfx->CacheSlots[index]) { RDPGFX_EVICT_CACHE_ENTRY_PDU pdu; pdu.cacheSlot = (UINT16) index; if (context) { IFCALLRET(context->EvictCacheEntry, error, context, &pdu); if (error) { WLog_Print(gfx->log, WLOG_ERROR, "context->EvictCacheEntry failed with error %"PRIu32"", error); free(context); free(gfx); return error; } } gfx->CacheSlots[index] = NULL; } } free(context); free(gfx); return CHANNEL_RC_OK; }
void AsyncHashTable_Uninitialize(AsyncHashTable* self) { assert(self != NULL); HashTable_Free(self->BaseTable); SAL_Mutex_Free(self->Lock); }
static MsgCatalog * MsgLoadCatalog(const char *path) { gchar *localPath; GError *err = NULL; GIOChannel *stream; gboolean error = FALSE; MsgCatalog *catalog = NULL; HashTable *dict; ASSERT(path != NULL); localPath = VMTOOLS_GET_FILENAME_LOCAL(path, NULL); ASSERT(localPath != NULL); stream = g_io_channel_new_file(localPath, "r", &err); VMTOOLS_RELEASE_FILENAME_LOCAL(localPath); if (err != NULL) { g_debug("Unable to open '%s': %s\n", path, err->message); g_clear_error(&err); return NULL; } dict = HashTable_Alloc(8, HASH_STRING_KEY | HASH_FLAG_COPYKEY, g_free); ASSERT_MEM_ALLOC(dict); for (;;) { gboolean eof = FALSE; char *name = NULL; char *value = NULL; gchar *line; /* Read the next key / value pair. */ for (;;) { gsize i; gsize len; gsize term; char *unused = NULL; gboolean cont = FALSE; g_io_channel_read_line(stream, &line, &len, &term, &err); if (err != NULL) { g_warning("Unable to read a line from '%s': %s\n", path, err->message); g_clear_error(&err); error = TRUE; g_free(line); break; } if (line == NULL) { eof = TRUE; break; } /* * Fix the line break to always be Unix-style, to make lib/dict * happy. */ if (line[term] == '\r') { line[term] = '\n'; if (len > term) { line[term + 1] = '\0'; } } /* * If currently name is not NULL, then check if this is a continuation * line and, if it is, just append the contents to the current value. */ if (term > 0 && name != NULL && line[term - 1] == '"') { for (i = 0; i < len; i++) { if (line[i] == '"') { /* OK, looks like a continuation line. */ char *tmp; char *unescaped; line[term - 1] = '\0'; unescaped = Escape_Undo('|', line + i + 1, len - i, NULL); tmp = Str_Asprintf(NULL, "%s%s", value, unescaped); free(unescaped); free(value); value = tmp; cont = TRUE; break; } else if (line[i] != ' ' && line[i] != '\t') { break; } } } /* * If not a continuation line and we have a name, break out of the * inner loop to update the dictionaty. */ if (!cont && name != NULL) { g_free(line); break; } /* * Finally, try to parse the string using the dictionary library. */ if (!cont && DictLL_UnmarshalLine(line, len, &unused, &name, &value) == NULL) { g_warning("Couldn't parse line from catalog: %s", line); error = TRUE; } g_free(line); free(unused); } if (error) { break; } if (name != NULL) { ASSERT(value); if (!Unicode_IsBufferValid(name, strlen(name) + 1, STRING_ENCODING_UTF8) || !Unicode_IsBufferValid(value, strlen(value) + 1, STRING_ENCODING_UTF8)) { g_warning("Invalid UTF-8 string in message catalog (key = %s)\n", name); error = TRUE; break; } MsgUnescape(value); HashTable_ReplaceOrInsert(dict, name, g_strdup(value)); free(name); free(value); name = NULL; value = NULL; } if (eof) { break; } } g_io_channel_unref(stream); if (error) { HashTable_Free(dict); dict = NULL; } else { catalog = g_new0(MsgCatalog, 1); catalog->utf8 = dict; } return catalog; }