예제 #1
0
파일: vector.cpp 프로젝트: OPM/ResInsight
void vector_clear(vector_type * vector) {
  int i;
  for (i = 0; i < vector->size; i++) {
    node_data_free(vector->data[i]);  /* User specific destructors are called here. */
    vector->data[i] = NULL;           /* This is essential to protect against unwaranted calls to destructors when data is reused. */
  }
  vector->size = 0;
}
예제 #2
0
파일: nodes.c 프로젝트: lucab/gtk-gnutella
static void 
free_node_data(const void *unused_key, void *value, void *unused_udata)
{
	(void) unused_key;
	(void) unused_udata;
	
	node_data_free(value);
}
예제 #3
0
파일: vector.cpp 프로젝트: OPM/ResInsight
void vector_idel(vector_type * vector , int index) {
  if ((index >= 0) && (index < vector->size)) {
    node_data_type * node = vector->data[index];
    node_data_free( node );  /* Discard the element */
    {
      int bytes_to_move = (vector->size - 1 - index) * sizeof * vector->data;
      memmove(&vector->data[index] , &vector->data[index + 1] , bytes_to_move);
      vector->data[vector->size - 1] = NULL;  /* Clear the last element  - which is no longer valid. */
      vector->size--;
    }
  } else
    util_abort("%s: Invalid index:%d  Valid range: [0,%d> \n",__func__ , index , vector->size);
}
예제 #4
0
파일: vector.cpp 프로젝트: OPM/ResInsight
static void vector_iset__(vector_type * vector , int index , node_data_type * node) {
  if (index > vector->size)
    vector_grow_NULL( vector , index );

  if (index == vector->size)
    vector_append_node( vector , node );
  else {
    if (vector->data[index] != NULL)
      node_data_free( vector->data[index] );

    vector->data[index] = node;
  }
}
예제 #5
0
파일: vector.cpp 프로젝트: OPM/ResInsight
static void vector_resize__(vector_type * vector, int new_alloc_size) {
  int i;
  if (new_alloc_size < vector->alloc_size) {
    /* The vector is shrinking. */
    for (i=new_alloc_size; i < vector->alloc_size; i++)
      node_data_free( vector->data[i] );
  }

  vector->data = (node_data_type**)util_realloc( vector->data , new_alloc_size * sizeof * vector->data );
  for (i = vector->alloc_size; i < new_alloc_size; i++)
    vector->data[i] = NULL; /* Initialising new nodes to NULL */

  vector->alloc_size = new_alloc_size;
}
예제 #6
0
파일: nodes.c 프로젝트: lucab/gtk-gnutella
/**
 * Removes all references to the given node handle in the gui.
 */
void
nodes_gui_remove_node(const struct nid *node_id)
{
	struct node_data *data;

    /*
     * Make sure node is removed from the "changed" hash tables so
     * we don't try an update later.
     */

	remove_item(ht_node_info_changed, node_id);
	remove_item(ht_node_flags_changed, node_id);
	remove_item(ht_pending_lookups, node_id);

	data = find_node(node_id);
	if (data) {
		g_assert(nid_equal(node_id, data->node_id));

		gtk_list_store_remove(nodes_model, &data->iter);
		htable_remove(nodes_handles, data->node_id);
		node_data_free(data);
	}
}
예제 #7
0
void hash_node_free(hash_node_type * node) {
  free(node->key);
  node_data_free( node->data );
  free(node);
}