예제 #1
0
void OtnLookupFree(SFGHASH *otn_map)
{
    if (otn_map == NULL)
        return;

    sfghash_delete(otn_map);
}
예제 #2
0
void SoRuleOtnLookupFree(SFGHASH *so_rule_otn_map)
{
    if (so_rule_otn_map == NULL)
        return;

    sfghash_delete(so_rule_otn_map);
}
예제 #3
0
void PreprocessorRuleOptionsFree(SFGHASH *preproc_rule_options)
{
    if (preproc_rule_options == NULL)
        return;

    sfghash_delete(preproc_rule_options);
}
예제 #4
0
void hostPortAppCacheFini()
{
    if (hostPortCache)
    {
        sfghash_delete(hostPortCache);
        hostPortCache = NULL;
    }
}
예제 #5
0
void sfthd_objs_free(ThresholdObjects *thd_objs)
{
    int i;
    tSfPolicyId policyId;

    if (thd_objs == NULL)
        return;

    for (i = 0; i < THD_MAX_GENID; i++)
    {
        if (thd_objs->sfthd_array[i])
            sfghash_delete(thd_objs->sfthd_array[i]);
    }

    for (policyId = 0; policyId < thd_objs->numPoliciesAllocated; policyId++)
    {
        if (thd_objs->sfthd_garray[policyId] == NULL)
            continue;

        if (thd_objs->sfthd_garray[policyId][0] != NULL)
        {
            sfthd_node_free((void *)thd_objs->sfthd_garray[policyId][0]);

            /* Free any individuals */
            for (i = 0; i < THD_MAX_GENID; i++)
            {
                if (thd_objs->sfthd_garray[policyId][i] !=
                    thd_objs->sfthd_garray[policyId][0])
                {
                    sfthd_node_free(
                        (void *)thd_objs->sfthd_garray[policyId][i]);
                }
            }

        }
        else
        {
            /* Anything other GID will be allocated individually */
            for (i = 1; i < THD_MAX_GENID; i++)
            {
                if (thd_objs->sfthd_garray[policyId][i])
                {
                    sfthd_node_free((void *)thd_objs->sfthd_garray[policyId][i]);
                }
            }
        }

        free(thd_objs->sfthd_garray[policyId]);
    }

    if (thd_objs->sfthd_garray != NULL)
        free(thd_objs->sfthd_garray);

    free(thd_objs);
}
예제 #6
0
int sfatom_reset()
{
    atom_first = 1;

    sfghash_delete( g_atom );

    if( sfatom_init() )
    {
      return SFGHASH_ERR;
    }

    return SFGHASH_OK;
}
예제 #7
0
파일: rate_filter.c 프로젝트: sdnnfv/snort
/* Free threshold context
 * @param pContext pointer to global threshold context.
 */
void RateFilter_ConfigFree(RateFilterConfig *config)
{
    int i;

    if (config == NULL)
        return;

    for (i = 0; i < SFRF_MAX_GENID; i++)
    {
        if (config->genHash[i] != NULL)
            sfghash_delete(config->genHash[i]);
    }

    free(config);
}
예제 #8
0
/*
*       Hash test program  
*/
int main ( int argc, char ** argv )
{
   int         i;
   SFGHASH      * t;
   SFGHASH_NODE * n, *m;
   char str[256],*p;
   int  num=100;

   if( argc > 1 )
       num = atoi(argv[1]);

   sfatom_init();

   /* Create a Hash Table */
   t = sfghash_new( 1000, 0 , GH_COPYKEYS , myfree  );

   /* Add Nodes to the Hash Table */
   for(i=0;i<num;i++) 
   {
       snprintf(str, sizeof(str), "KeyWord%d",i+1);
       str[sizeof(str) - 1] = '\0';
       sfghash_add( t, str,  strupr(strdup(str)) );

       sfatom_add( str,  strupr(strdup(str)) );
   }  

   /* Find and Display Nodes in the Hash Table */
   printf("\n** FIND KEY TEST\n");

   for(i=0;i<num;i++) 
   {
      snprintf(str, sizeof(str), "KeyWord%d",i+1);
      str[sizeof(str) - 1] = '\0';

      p = (char*) sfghash_find( t, str );

      printf("Hash-key=%*s, data=%*s\n", strlen(str),str, strlen(str), p );

      p = (char*) sfatom_find( str );

      printf("Atom-key=%*s, data=%*s\n", strlen(str),str, strlen(str), p );
   }  

   /* Display All Nodes in the Hash Table */
   printf("\n** FINDFIRST / FINDNEXT TEST\n");

   for( n = sfghash_findfirst(t); n; n = sfghash_findnext(t) )
   {
      printf("hash-findfirst/next: key=%s, data=%s\n", n->key, n->data );

      // hashing code frees user data using 'myfree' above ....
      if( sfghash_remove(t,n->key) ) 
            printf("Could not remove the key node\n");
      else  
            printf("key node removed\n");
   }

   for( n = sfatom_findfirst(); n; n = sfatom_findnext() )
   {
      printf("atom-findfirst/next: key=%s, data=%s\n", n->key, n->data );

      free( n->data );  //since atom data is not freed automatically
   }

   /* Free the table and it's user data */
   printf("****sfghash_delete\n");
   sfghash_delete( t );

   printf("****sfatom_reset\n");
   sfatom_reset();

   printf("\nnormal pgm finish\n\n");

   return 0;
}
예제 #9
0
void sfdict_delete( SFDICT * h )
{
    sfghash_delete( h );
}