コード例 #1
0
ファイル: stream.c プロジェクト: RazZziel/wireshark-dplay
/* init/reset function, call from stream_init() */
static void init_fragment_hash( void ) {
    if( fragment_hash != NULL ) {
	g_hash_table_destroy( fragment_hash );
	fragment_hash = NULL;
    }

    if( fragment_vals != NULL ) {
	g_mem_chunk_destroy( fragment_vals );
	fragment_vals = NULL;
    }

    if( fragment_keys != NULL ) {
	g_mem_chunk_destroy( fragment_keys );
	fragment_keys = NULL;
    }

    fragment_keys = g_mem_chunk_create(fragment_key_t,
				       MEMCHUNK_FRAGMENT_COUNT,
				       G_ALLOC_ONLY);
    
    fragment_vals = g_mem_chunk_create(stream_pdu_fragment_t,
				       MEMCHUNK_FRAGMENT_COUNT,
				       G_ALLOC_ONLY);

    fragment_hash = g_hash_table_new(fragment_hash_func,
				     fragment_compare_func);
}
コード例 #2
0
ファイル: stream.c プロジェクト: RazZziel/wireshark-dplay
/* init/reset function, call from stream_init() */
static void init_stream_hash( void ) {
    if( stream_hash != NULL ) {
	g_hash_table_destroy( stream_hash );
	stream_hash = NULL;
    }

    if( stream_keys != NULL ) {
	g_mem_chunk_destroy( stream_keys );
	stream_keys = NULL;
    }

    if( streams != NULL ) {
	g_mem_chunk_destroy( streams );
	streams = NULL;
    }

    streams = g_mem_chunk_create(stream_t,
				 MEMCHUNK_STREAM_COUNT,
				 G_ALLOC_ONLY);

    stream_keys = g_mem_chunk_create(stream_key_t,
				     MEMCHUNK_STREAM_COUNT,
				     G_ALLOC_ONLY);

    stream_hash = g_hash_table_new(stream_hash_func,
				   stream_compare_func);
}
コード例 #3
0
ファイル: data1.c プロジェクト: kroody/codesnippet
int	main(int argc, char *argv[])
{
	GMemChunk *chunk;	//定义内存块
	gchar *mem[10];	//定义指向原子的指针数组
	gint i, j;
	//创建内存块
	chunk = g_mem_chunk_new("Test MemChunk", 5, 50, G_ALLOC_AND_FREE);
				//名称,原子的长度, 内存块的长度,类型
	for(i=0; i<10; i++)
	{
		//创建对象
		//mem[i] = g_chunk_new(gchar, chunk);
		mem[i] = (gchar*)g_mem_chunk_alloc(chunk);
		for(j=0; j<5; j++)
		{
			mem[i][j] = 'A' + j;//为内存块中的指针赋值
		}
	}
	
	g_mem_chunk_print(chunk);	//显示内存块信息
	for(i=0; i<10; i++)
	{
		g_print("%s\t",mem[i]);//显示内存块中的内容
	}
	
	for(i=0; i<10; i++)
	{
		g_mem_chunk_free(chunk,mem[i]); //释放所有分配的内存
	}
	g_mem_chunk_destroy(chunk);
}
コード例 #4
0
ファイル: ghook.c プロジェクト: 0x0all/ROOT
void
g_hook_list_clear (GHookList *hook_list)
{
  g_return_if_fail (hook_list != NULL);
  
  if (hook_list->is_setup)
    {
      GHook *hook;
      
      hook_list->is_setup = FALSE;
      
      hook = hook_list->hooks;
      if (!hook)
	{
	  g_mem_chunk_destroy (hook_list->hook_memchunk);
	  hook_list->hook_memchunk = NULL;
	}
      else
	do
	  {
	    GHook *tmp;
	    
	    g_hook_ref (hook_list, hook);
	    g_hook_destroy_link (hook_list, hook);
	    tmp = hook->next;
	    g_hook_unref (hook_list, hook);
	    hook = tmp;
	  }
	while (hook);
      if (hook_list->hook_memchunk)
	g_warning (G_STRLOC ": failed to clear hooklist, unconsolidated references on hooks left");
    }
}
コード例 #5
0
ファイル: gslist.c プロジェクト: AllardJ/Tomato
/* HOLDS: current_allocator_lock */
static void
g_slist_validate_allocator (GAllocator *allocator)
{
  g_return_if_fail (allocator != NULL);
  g_return_if_fail (allocator->is_unused == TRUE);

  if (allocator->type != G_ALLOCATOR_SLIST)
    {
      allocator->type = G_ALLOCATOR_SLIST;
      if (allocator->mem_chunk)
	{
	  g_mem_chunk_destroy (allocator->mem_chunk);
	  allocator->mem_chunk = NULL;
	}
    }

  if (!allocator->mem_chunk)
    {
      allocator->mem_chunk = g_mem_chunk_new (allocator->name,
					      sizeof (GSList),
					      sizeof (GSList) * allocator->n_preallocs,
					      G_ALLOC_ONLY);
      allocator->free_lists = NULL;
    }

  allocator->is_unused = FALSE;
}
コード例 #6
0
ファイル: fileh.cpp プロジェクト: ottimo/stress
void CaptureFile::resetState() {
    /* Die if we're in the middle of reading a file. */
    //	g_assert(state != FILE_READ_IN_PROGRESS); //FIXME controllo?

    if (wth) {
        wtap_close(wth);
        wth = NULL;
    }


#if GLIB_CHECK_VERSION(2,10,0)
    if (plist != NULL)
        g_slice_free_chain(frame_data, plist, next);
#else
    if (plist_chunk != NULL) {
        frame_data *fdata = plist;
        while (fdata) {
            g_strfreev(fdata->col_expr.col_expr);
            g_strfreev(fdata->col_expr.col_expr_val);
            fdata = fdata->next;
        }
        /* memory chunks have been deprecated in favor of the slice allocator,
         * which has been added in 2.10
         */
        g_mem_chunk_destroy(plist_chunk);
        plist_chunk = NULL;
    }
#endif
    if (rfcode != NULL) {
        dfilter_free(rfcode);
        rfcode = NULL;
    }
    plist = NULL;
    plist_end = NULL;
    //	cf_unselect_packet(cf);	/* nothing to select */
    //    first_displayed = NULL;
    //    last_displayed = NULL;
    //
    //    /* No frame selected, no field in that frame selected. */
    //    current_frame = NULL;
    //    current_row = 0;
    //    finfo_selected = NULL;

    /* Clear the packet list. */
    //	packet_list_freeze();
    //	packet_list_clear();
    //	packet_list_thaw();

    f_datalen = 0;
    count = 0;
    //nstime_set_zero(&elapsed_time);

    //  reset_tap_listeners();

    /* We have no file open. */
    state = FILE_CLOSED;

    //fileset_file_closed();
}
コード例 #7
0
ファイル: .c プロジェクト: pigay/vsg
static void vsg_quaternion@t@_finalize ()
{
  if (vsg_quaternion@t@_mem_chunk)
    {
      g_mem_chunk_destroy (vsg_quaternion@t@_mem_chunk);
      vsg_quaternion@t@_mem_chunk = 0;
    }
}
コード例 #8
0
ファイル: signals.c プロジェクト: svn2github/irssi
void signals_deinit(void)
{
	g_hash_table_foreach(signals, (GHFunc) signal_free, NULL);
	g_hash_table_destroy(signals);

	module_uniq_destroy("signals");
	g_mem_chunk_destroy(signals_chunk);
}
コード例 #9
0
ファイル: .c プロジェクト: BackupTheBerlios/vsg-svn
static void vsg_matrix3@t@_finalize ()
{
  if (vsg_matrix3@t@_mem_chunk)
    {
      g_mem_chunk_destroy (vsg_matrix3@t@_mem_chunk);
      vsg_matrix3@t@_mem_chunk = 0;
    }
}
コード例 #10
0
static void aran_solver3d_finalize ()
{
  if (aran_solver3d_mem_chunk)
    {
      g_mem_chunk_destroy (aran_solver3d_mem_chunk);
      aran_solver3d_mem_chunk = 0;
    }
}
コード例 #11
0
ファイル: .c プロジェクト: BackupTheBerlios/vsg-svn
static void vsg_vector2@t@_finalize ()
{
  if (vsg_vector2@t@_mem_chunk)
    {
      g_mem_chunk_destroy (vsg_vector2@t@_mem_chunk);
      vsg_vector2@t@_mem_chunk = 0;
    }
}
コード例 #12
0
ファイル: stream.c プロジェクト: RazZziel/wireshark-dplay
static void stream_init_pdu_data(void)
{
    if( pdus != NULL ) {
	g_mem_chunk_destroy( pdus );
	pdus = NULL;
    }

    pdus = g_mem_chunk_create(stream_pdu_t,
			      MEMCHUNK_PDU_COUNT,
			      G_ALLOC_ONLY);
    pdu_counter = 0;
}
コード例 #13
0
ファイル: gui-windows.c プロジェクト: svn2github/irssi
static void gui_window_deinit(GUI_WINDOW_REC *gui)
{
    g_hash_table_foreach(gui->line_cache, (GHFunc) line_cache_destroy, NULL);
    g_hash_table_destroy(gui->line_cache);

    g_slist_foreach(gui->text_chunks, (GFunc) g_free, NULL);
    g_slist_free(gui->text_chunks);

    g_mem_chunk_destroy(gui->line_chunk);
    g_list_free(gui->lines);

    g_free(gui);
}
コード例 #14
0
ファイル: hash.c プロジェクト: JeffAbrahamson/cryptar
/* Deallocate all buckets.
 */
static void hash_clear()
{
        guint32 i;

        g_assert(hash_table);
        for(i = 0; i < hash_size; i++) {
                if(hash_table[i])
                        g_slist_free(hash_table[i]);
        }
        g_assert(entry_pool);
        g_mem_chunk_destroy(entry_pool);
        entry_pool = 0;
        return;
}
コード例 #15
0
ファイル: ghook.c プロジェクト: 0x0all/ROOT
void
g_hook_unref (GHookList *hook_list,
	      GHook	*hook)
{
  g_return_if_fail (hook_list != NULL);
  g_return_if_fail (hook_list->hook_memchunk != NULL);
  g_return_if_fail (hook != NULL);
  g_return_if_fail (hook->ref_count > 0);
  
  hook->ref_count--;
  if (!hook->ref_count)
    {
      g_return_if_fail (hook->hook_id == 0);
      g_return_if_fail (!G_HOOK_IN_CALL (hook));

      if (hook->prev)
	hook->prev->next = hook->next;
      else
	hook_list->hooks = hook->next;
      if (hook->next)
	{
	  hook->next->prev = hook->prev;
	  hook->next = NULL;
	}
      hook->prev = NULL;

      if (!hook_list->is_setup)
	{
	  hook_list->is_setup = TRUE;
	  g_hook_free (hook_list, hook);
	  hook_list->is_setup = FALSE;
      
	  if (!hook_list->hooks)
	    {
	      g_mem_chunk_destroy (hook_list->hook_memchunk);
	      hook_list->hook_memchunk = NULL;
	    }
	}
      else
	g_hook_free (hook_list, hook);
    }
}
コード例 #16
0
ファイル: gtktypeutils.c プロジェクト: Onjrew/OpenEV
void
gtk_type_set_chunk_alloc (GtkType      type,
			  guint	       n_chunks)
{
  GtkTypeNode *node;
  
  LOOKUP_TYPE_NODE (node, type);
  g_return_if_fail (node != NULL);
  g_return_if_fail (node->chunk_alloc_locked == FALSE);
  
  if (node->mem_chunk)
    {
      g_mem_chunk_destroy (node->mem_chunk);
      node->mem_chunk = NULL;
    }
  
  if (n_chunks)
    node->mem_chunk = g_mem_chunk_new (node->type_info.type_name,
				       node->type_info.object_size,
				       node->type_info.object_size * n_chunks,
				       G_ALLOC_AND_FREE);
}
コード例 #17
0
void
g_relation_destroy (GRelation *relation)
{
  gint i;
  
  if (relation)
    {
      g_hash_table_destroy (relation->all_tuples);
      g_mem_chunk_destroy (relation->tuple_chunk);
      
      for (i = 0; i < relation->fields; i += 1)
	{
	  if (relation->hashed_tuple_tables[i])
	    {
	      g_hash_table_foreach (relation->hashed_tuple_tables[i], g_relation_free_array, NULL);
	      g_hash_table_destroy (relation->hashed_tuple_tables[i]);
	    }
	}
      
      g_free (relation->hashed_tuple_tables);
      g_free (relation);
    }
}
コード例 #18
0
ファイル: textbuffer.c プロジェクト: svn2github/irssi
void textbuffer_deinit(void)
{
	g_mem_chunk_destroy(buffer_chunk);
	g_mem_chunk_destroy(line_chunk);
	g_mem_chunk_destroy(text_chunk);
}