static void destroyHashTables( void ) //*********************************** { if( SymbolToTargetTable ) HashTableFree( SymbolToTargetTable ); if( SymbolToExportTable ) HashTableFree( SymbolToExportTable ); if( SectionToSegmentTable ) HashTableFree( SectionToSegmentTable ); }
static int HashTableTestFull02 (void) { int result = 0; HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL); if (ht == NULL) goto end; int r = HashTableAdd(ht, "test", 4); if (r != 0) goto end; char *rp = HashTableLookup(ht, "test", 4); if (rp == NULL) goto end; r = HashTableRemove(ht, "test2", 5); if (r == 0) goto end; /* all is good! */ result = 1; end: if (ht != NULL) HashTableFree(ht); return result; }
static int HashTableTestInit04 (void) { HashTable *ht = HashTableInit(0, HashTableGenericHash, NULL, NULL); if (ht == NULL) return 1; HashTableFree(ht); return 0; }
/* no hash function, so it should fail */ static int HashTableTestInit02 (void) { HashTable *ht = HashTableInit(1024, NULL, NULL, NULL); if (ht == NULL) return 1; HashTableFree(ht); return 0; }
/** * \brief Inits the context to be used by the Classification Config parsing API. * * This function initializes the hash table to be used by the Detection * Engine Context to hold the data from the classification.config file, * obtains the file desc to parse the classification.config file, and * inits the regex used to parse the lines from classification.config * file. * * \param de_ctx Pointer to the Detection Engine Context. * * \retval 0 On success. * \retval -1 On failure. */ int SCClassConfInitContext(DetectEngineCtx *de_ctx) { char *filename = NULL; const char *eb = NULL; int eo; int opts = 0; /* init the hash table to be used by the classification config Classtypes */ de_ctx->class_conf_ht = HashTableInit(4096, SCClassConfClasstypeHashFunc, SCClassConfClasstypeHashCompareFunc, SCClassConfClasstypeHashFree); if (de_ctx->class_conf_ht == NULL) { SCLogError(SC_ERR_HASH_TABLE_INIT, "Error initializing the hash " "table"); return -1; } /* if it is not NULL, use the file descriptor. The hack so that we can * avoid using a dummy classification file for testing purposes and * instead use an input stream against a buffer containing the * classification strings */ if (fd == NULL) { filename = SCClassConfGetConfFilename(); if ( (fd = fopen(filename, "r")) == NULL) { SCLogError(SC_ERR_FOPEN, "Error opening file: \"%s\": %s", filename, strerror(errno)); goto error; } } regex = pcre_compile(DETECT_CLASSCONFIG_REGEX, opts, &eb, &eo, NULL); if (regex == NULL) { SCLogDebug("Compile of \"%s\" failed at offset %" PRId32 ": %s", DETECT_CLASSCONFIG_REGEX, eo, eb); goto error; } regex_study = pcre_study(regex, 0, &eb); if (eb != NULL) { SCLogDebug("pcre study failed: %s", eb); goto error; } return 0; error: if (de_ctx->class_conf_ht != NULL) { HashTableFree(de_ctx->class_conf_ht); de_ctx->class_conf_ht = NULL; } if (fd != NULL) { fclose(fd); fd = NULL; } printf("\nPlease check the \"classification-file\" option in your suricata.yaml file.\n"); exit(EXIT_FAILURE); // return -1; }
/** * \brief Inits the context to be used by the Reference Config parsing API. * * This function initializes the hash table to be used by the Detection * Engine Context to hold the data from reference.config file, * obtains the file descriptor to parse the reference.config file, and * inits the regex used to parse the lines from reference.config file. * * \param de_ctx Pointer to the Detection Engine Context. * * \retval 0 On success. * \retval -1 On failure. */ static int SCRConfInitContext(DetectEngineCtx *de_ctx) { char *filename = NULL; const char *eb = NULL; int eo; int opts = 0; /* init the hash table to be used by the reference config references */ de_ctx->reference_conf_ht = HashTableInit(128, SCRConfReferenceHashFunc, SCRConfReferenceHashCompareFunc, SCRConfReferenceHashFree); if (de_ctx->reference_conf_ht == NULL) { SCLogError(SC_ERR_HASH_TABLE_INIT, "Error initializing the hash " "table"); return -1; } /* if it is not NULL, use the file descriptor. The hack so that we can * avoid using a dummy reference file for testing purposes and * instead use an input stream against a buffer containing the * reference strings */ if (fd == NULL) { filename = SCRConfGetConfFilename(); if ((fd = fopen(filename, "r")) == NULL) { SCLogError(SC_ERR_FOPEN, "Error opening file: \"%s\": %s", filename, strerror(errno)); goto error; } } regex = pcre_compile(SC_RCONF_REGEX, opts, &eb, &eo, NULL); if (regex == NULL) { SCLogDebug("Compile of \"%s\" failed at offset %" PRId32 ": %s", SC_RCONF_REGEX, eo, eb); goto error; } regex_study = pcre_study(regex, 0, &eb); if (eb != NULL) { SCLogDebug("pcre study failed: %s", eb); goto error; } return 0; error: if (de_ctx->reference_conf_ht != NULL) { HashTableFree(de_ctx->reference_conf_ht); de_ctx->reference_conf_ht = NULL; } if (fd != NULL) { fclose(fd); fd = NULL; } return -1; }
/** * \brief Releases de_ctx resources related to Reference Config API. */ void SCRConfDeInitContext(DetectEngineCtx *de_ctx) { if (de_ctx->reference_conf_ht != NULL) HashTableFree(de_ctx->reference_conf_ht); de_ctx->reference_conf_ht = NULL; return; }
/** * \brief Releases resources used by the Classification Config API. */ void SCClassConfDeInitContext(DetectEngineCtx *de_ctx) { if (de_ctx->class_conf_ht != NULL) HashTableFree(de_ctx->class_conf_ht); de_ctx->class_conf_ht = NULL; return; }
static int HashTableTestInit03 (void) { int result = 0; HashTable *ht = HashTableInit(1024, HashTableGenericHash, NULL, NULL); if (ht == NULL) return 0; if (ht->Hash == HashTableGenericHash) result = 1; HashTableFree(ht); return result; }
static int HashTableTestInit06 (void) { int result = 0; HashTable *ht = HashTableInit(1024, HashTableGenericHash, HashTableDefaultCompareTest, NULL); if (ht == NULL) return 0; if (ht->Compare == HashTableDefaultCompareTest) result = 1; HashTableFree(ht); return result; }
void FreeHashTables( void ) { HashTableFree( HandleToSectionTable ); HashTableFree( SymbolToLabelTable ); HashTableFree( HandleToLabelListTable ); HashTableFree( HandleToRefListTable ); HashTableFree( NameRecognitionTable ); HashTableFree( SkipRefTable ); }
void _CDECL_ PiggyClose (void) { int i, j; tDigiSound *dsP; PrintLog ("unloading textures\n"); PiggyCloseFile (); PrintLog ("unloading sounds\n"); for (i = 0; i < 2; i++) { for (j = 0, dsP = gameData.pig.sound.sounds [i]; j < MAX_SOUND_FILES; j++, dsP++) if (dsP->bHires) { D2_FREE (dsP->data [0]); dsP->bHires = 0; } else if (dsP->bDTX) { D2_FREE (dsP->data [1]); dsP->bDTX = 0; } if (gameData.pig.sound.data [i]) D2_FREE (gameData.pig.sound.data [i]); HashTableFree (bitmapNames + i); HashTableFree (soundNames + i); } }
static int HashTableTestAdd02 (void) { int result = 0; HashTable *ht = HashTableInit(32, HashTableGenericHash, NULL, NULL); if (ht == NULL) goto end; int r = HashTableAdd(ht, NULL, 4); if (r == 0) goto end; /* all is good! */ result = 1; end: if (ht != NULL) HashTableFree(ht); return result; }
/** * \brief Inits the context to be used by the Reference Config parsing API. * * This function initializes the hash table to be used by the Detection * Engine Context to hold the data from reference.config file, * obtains the file descriptor to parse the reference.config file, and * inits the regex used to parse the lines from reference.config file. * * \param de_ctx Pointer to the Detection Engine Context. * * \retval 0 On success. * \retval -1 On failure. */ static FILE *SCRConfInitContextAndLocalResources(DetectEngineCtx *de_ctx, FILE *fd) { char *filename = NULL; /* init the hash table to be used by the reference config references */ de_ctx->reference_conf_ht = HashTableInit(128, SCRConfReferenceHashFunc, SCRConfReferenceHashCompareFunc, SCRConfReferenceHashFree); if (de_ctx->reference_conf_ht == NULL) { SCLogError(SC_ERR_HASH_TABLE_INIT, "Error initializing the hash " "table"); goto error; } /* if it is not NULL, use the file descriptor. The hack so that we can * avoid using a dummy reference file for testing purposes and * instead use an input stream against a buffer containing the * reference strings */ if (fd == NULL) { filename = SCRConfGetConfFilename(); if ((fd = fopen(filename, "r")) == NULL) { #ifdef UNITTESTS if (RunmodeIsUnittests()) goto error; // silently fail #endif SCLogError(SC_ERR_FOPEN, "Error opening file: \"%s\": %s", filename, strerror(errno)); goto error; } } return fd; error: if (de_ctx->reference_conf_ht != NULL) { HashTableFree(de_ctx->reference_conf_ht); de_ctx->reference_conf_ht = NULL; } if (fd != NULL) { fclose(fd); fd = NULL; } return NULL; }
static return_val createHashTables( void ) { HandleToSectionTable = HashTableCreate( HANDLE_TO_SECTION_TABLE_SIZE, HASH_HANDLE ); if( HandleToSectionTable != NULL ) { HandleToLabelListTable = HashTableCreate( HANDLE_TO_LIST_TABLE_SIZE, HASH_HANDLE ); if( HandleToLabelListTable != NULL ) { HandleToRefListTable = HashTableCreate( HANDLE_TO_LIST_TABLE_SIZE, HASH_HANDLE ); if( HandleToRefListTable != NULL ) { SymbolToLabelTable = HashTableCreate( SYMBOL_TO_LABEL_TABLE_SIZE, HASH_HANDLE ); if( SymbolToLabelTable != NULL ) { NameRecognitionTable = HashTableCreate( RECOGNITION_TABLE_SIZE, HASH_STRING_IGNORECASE ); if( NameRecognitionTable == NULL ) { HashTableFree( HandleToSectionTable ); HashTableFree( HandleToSectionTable ); HashTableFree( HandleToLabelListTable ); HashTableFree( HandleToRefListTable ); HashTableFree( SymbolToLabelTable ); return( RC_OUT_OF_MEMORY ); } } else { HashTableFree( HandleToSectionTable ); HashTableFree( HandleToLabelListTable ); HashTableFree( HandleToRefListTable ); return( RC_OUT_OF_MEMORY ); } } else { HashTableFree( HandleToSectionTable ); HashTableFree( HandleToLabelListTable ); return( RC_OUT_OF_MEMORY ); } } else { HashTableFree( HandleToSectionTable ); return( RC_OUT_OF_MEMORY ); } } else { return( RC_OUT_OF_MEMORY ); } return( RC_OKAY ); }
static return_val createHashTables( void ) { HandleToSectionTable = HashTableCreate( HANDLE_TO_SECTION_TABLE_SIZE, HASH_NUMBER, NumberCmp ); if( HandleToSectionTable ) { HandleToLabelListTable = HashTableCreate( HANDLE_TO_LIST_TABLE_SIZE, HASH_NUMBER, NumberCmp ); if( HandleToLabelListTable ) { HandleToRefListTable = HashTableCreate( HANDLE_TO_LIST_TABLE_SIZE, HASH_NUMBER, NumberCmp ); if( HandleToRefListTable ) { SymbolToLabelTable = HashTableCreate( SYMBOL_TO_LABEL_TABLE_SIZE, HASH_NUMBER, NumberCmp ); if( SymbolToLabelTable ) { NameRecognitionTable = HashTableCreate( RECOGNITION_TABLE_SIZE, HASH_STRING, (hash_table_comparison_func) stricmp ); if( !NameRecognitionTable ) { HashTableFree( HandleToSectionTable ); HashTableFree( HandleToSectionTable ); HashTableFree( HandleToLabelListTable ); HashTableFree( HandleToRefListTable ); HashTableFree( SymbolToLabelTable ); return( OUT_OF_MEMORY ); } } else { HashTableFree( HandleToSectionTable ); HashTableFree( HandleToLabelListTable ); HashTableFree( HandleToRefListTable ); return( OUT_OF_MEMORY ); } } else { HashTableFree( HandleToSectionTable ); HashTableFree( HandleToLabelListTable ); return( OUT_OF_MEMORY ); } } else { HashTableFree( HandleToSectionTable ); return( OUT_OF_MEMORY ); } } else { return( OUT_OF_MEMORY ); } return( OKAY ); }
void AsmFree(Assembler *a) { ArrayFree(a->codes, (FuncPtr1) AsmCodeFree); HashTableFree(a->symTable); OpTableFree(); ObjFree(a); }
void StringQuarksFree(void) { HashTableFree(quarks); quarks = NULL; }