guint object_hash(gconstpointer gp) { pointer p = (pointer)gp; if(is_symbol(p)) { return g_direct_hash(gp); } // TODO: call other hash functions based on type return g_direct_hash(gp); }
guint ipset_trinary_key_hash(ipset_trinary_key_t *key) { guint hash = 0; combine_hash(&hash, g_direct_hash(key->f)); combine_hash(&hash, g_direct_hash(key->g)); combine_hash(&hash, g_direct_hash(key->h)); return hash; }
/** * sksrc: a #SeahorseSource, part of the hash * id: an id, part of the hash * * Creates a hash out of @sksrc and @id * * Returns an int stored in a pointer, representing the hash **/ static gpointer hashkey_by_source (SeahorseSource *sksrc, GQuark id) { return GINT_TO_POINTER (g_direct_hash (sksrc) ^ g_str_hash (g_quark_to_string (id))); }
static guint item_hash_hash(gconstpointer key) { const struct item *itm=key; gconstpointer hashkey=(gconstpointer)GINT_TO_POINTER(itm->id_hi^itm->id_lo^(GPOINTER_TO_INT(itm->map))); return g_direct_hash(hashkey); }
static guint item_hash_hash(gconstpointer key) { const struct item *itm=key; gconstpointer hashkey=(gconstpointer)(itm->id_hi^itm->id_lo^((int) itm->map)); return g_direct_hash(hashkey); }
static guint search_item_hash_hash(gconstpointer key) { const struct item *itm=key; gconstpointer hashkey=(gconstpointer)(itm->id_hi^itm->id_lo); return g_direct_hash(hashkey); }
static void __cand_ice_foundation(struct call *call, struct ice_candidate *cand) { char buf[64]; int len; len = sprintf(buf, "%x%x%x", endpoint_hash(&cand->endpoint), cand->type, g_direct_hash(cand->transport)); call_str_cpy_len(call, &cand->foundation, buf, len); }
/** * gck_module_hash: * @module: A pointer to a GckModule * * Create a hash value for the GckModule. * * This function is intended for easily hashing a GckModule to add to * a GHashTable or similar data structure. * * Return value: An integer that can be used as a hash value, or 0 if invalid. **/ guint gck_module_hash (gconstpointer module) { GckModule *self; g_return_val_if_fail (GCK_IS_MODULE (module), 0); self = GCK_MODULE (module); return g_direct_hash (self->pv->funcs); }
static guint polkit_unix_group_hash (PolkitIdentity *identity) { PolkitUnixGroup *group; group = POLKIT_UNIX_GROUP (identity); return g_direct_hash (GINT_TO_POINTER (((gint) (group->gid)) * 2 + 1)); }
static guint log_viewer_hash(gconstpointer data) { const struct log_viewer_hash_t *viewer = data; if (viewer->contact != NULL) return g_direct_hash(viewer->contact); return g_str_hash(viewer->screenname) + g_str_hash(purple_account_get_username(viewer->account)); }
/** * gp11_module_hash: * @module: A pointer to a GP11Module * * Create a hash value for the GP11Module. * * This function is intended for easily hashing a GP11Module to add to * a GHashTable or similar data structure. * * Return value: An integer that can be used as a hash value, or 0 if invalid. **/ guint gp11_module_hash (gconstpointer module) { GP11ModuleData *data; g_return_val_if_fail (GP11_IS_MODULE (module), 0); data = GP11_MODULE_GET_DATA (module); return g_direct_hash (data->funcs); }
static const guint * _lib_backgroundjobs_create(dt_lib_module_t *self,int type,const gchar *message) { dt_lib_backgroundjobs_t *d = (dt_lib_backgroundjobs_t *)self->data; /* lets make this threadsafe */ gboolean i_own_lock = dt_control_gdk_lock(); /* initialize a new job */ dt_bgjob_t *j=(dt_bgjob_t*)g_malloc(sizeof(dt_bgjob_t)); j->type = type; j->widget = gtk_event_box_new(); guint *key = g_malloc(sizeof(guint)); *key = g_direct_hash((gconstpointer)j); /* create in hash out of j pointer*/ g_hash_table_insert(d->jobs, key, j); /* intialize the ui elements for job */ gtk_widget_set_name (GTK_WIDGET (j->widget), "background_job_eventbox"); GtkBox *vbox = GTK_BOX (gtk_vbox_new (FALSE,0)); GtkBox *hbox = GTK_BOX (gtk_hbox_new (FALSE,0)); gtk_container_set_border_width (GTK_CONTAINER(vbox),2); gtk_container_add (GTK_CONTAINER(j->widget), GTK_WIDGET(vbox)); /* add job label */ j->label = gtk_label_new(message); gtk_misc_set_alignment(GTK_MISC(j->label), 0.0, 0.5); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET(j->label), TRUE, TRUE, 0); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET(hbox), TRUE, TRUE, 0); /* use progressbar ? */ if (type == 0) { j->progressbar = gtk_progress_bar_new(); gtk_box_pack_start( GTK_BOX( vbox ), j->progressbar, TRUE, FALSE, 2); #ifdef HAVE_UNITY j->darktable_launcher = unity_launcher_entry_get_for_desktop_id("darktable.desktop"); unity_launcher_entry_set_progress( j->darktable_launcher, 0.0 ); unity_launcher_entry_set_progress_visible( j->darktable_launcher, TRUE ); #endif } /* lets show jobbox if its hidden */ gtk_box_pack_start(GTK_BOX(d->jobbox), j->widget, TRUE, FALSE, 1); gtk_box_reorder_child(GTK_BOX(d->jobbox), j->widget, 1); gtk_widget_show_all(j->widget); gtk_widget_show(d->jobbox); if(i_own_lock) dt_control_gdk_unlock(); return key; }
guint hippo_cookie_hash (HippoCookie *cookie) { guint hash; /* very scientific approach */ hash = g_direct_hash(GINT_TO_POINTER(cookie->origin_browser)); hash += g_str_hash(cookie->domain) * 37; hash += cookie->port * 37; hash += g_str_hash(cookie->path) * 37; hash += g_str_hash(cookie->name) * 37; return hash; }
static guint tm_file_inode_hash(gconstpointer key) { struct stat file_stat; const char *filename = (const char*)key; if (g_stat(filename, &file_stat) == 0) { #ifdef TM_DEBUG g_message ("Hash for '%s' is '%d'\n", filename, file_stat.st_ino); #endif return g_direct_hash (GUINT_TO_POINTER (file_stat.st_ino)); } else { return 0; } }
static guint tm_file_inode_hash(gconstpointer key) { GStatBuf file_stat; const char *filename = (const char*)key; if (g_stat(filename, &file_stat) == 0) { #ifdef TM_DEBUG g_message ("Hash for '%s' is '%d'\n", filename, file_stat.st_ino); #endif return g_direct_hash ((gpointer)(intptr_t)file_stat.st_ino); } else { return 0; } }
guint pred_hash(gconstpointer v) { return g_direct_hash(((pred_t *)v)->cond) + g_direct_hash(((pred_t *)v)->hist); }
guint key_hash(struct ObjCacheKey* key) { return g_str_hash(key->bus_name) + g_str_hash(key->path) + g_str_hash(key->iface) + g_direct_hash(key->connection); }
static guint gtk_source_completion_proposal_hash_default (GtkSourceCompletionProposal *proposal) { return g_direct_hash (proposal); }
/** * fo_object_hash_func_default: * @key: Pointer to object to hash. * * Default 'hash_func' which just returns object's address. * * Return value: Hash code for object. **/ guint fo_object_hash_func_default (gconstpointer key) { return g_direct_hash(key); }
static guint joinpart_key_hash(const struct joinpart_key *key) { g_return_val_if_fail(key != NULL, 0); return g_direct_hash(key->conv) + g_str_hash(key->user); }
static guint _purple_conversations_hconv_hash(struct _purple_hconv *hc) { return g_str_hash(hc->name) ^ hc->im ^ g_direct_hash(hc->account); }
static unsigned int __pair_hash(const void *p) { const struct ice_candidate_pair *pair = p; return g_direct_hash(pair->local_address) ^ g_direct_hash(pair->remote_candidate); }
/* Pass in the pspec so we can get the generic type. For example, a * held in a GParamSpec allowing OBJECT, but the value could be of type * VipsImage. generics are much faster to compare. */ static unsigned int vips_value_hash( GParamSpec *pspec, GValue *value ) { GType generic = G_PARAM_SPEC_TYPE( pspec ); /* Not compile-time constants, so we have to use a set of if()s. Could * make a table at run time I guess. */ if( generic == G_TYPE_PARAM_BOOLEAN ) return( (unsigned int) g_value_get_boolean( value ) ); else if( generic == G_TYPE_PARAM_CHAR ) return( (unsigned int) VIPS_VALUE_GET_CHAR( value ) ); else if( generic == G_TYPE_PARAM_UCHAR ) return( (unsigned int) g_value_get_uchar( value ) ); else if( generic == G_TYPE_PARAM_INT ) return( (unsigned int) g_value_get_int( value ) ); else if( generic == G_TYPE_PARAM_UINT ) return( (unsigned int) g_value_get_uint( value ) ); else if( generic == G_TYPE_PARAM_LONG ) return( (unsigned int) g_value_get_long( value ) ); else if( generic == G_TYPE_PARAM_ULONG ) return( (unsigned int) g_value_get_ulong( value ) ); else if( generic == G_TYPE_PARAM_ENUM ) return( (unsigned int) g_value_get_enum( value ) ); else if( generic == G_TYPE_PARAM_FLAGS ) return( (unsigned int) g_value_get_flags( value ) ); else if( generic == G_TYPE_PARAM_UINT64 ) { guint64 i = g_value_get_uint64( value ); return( INT64_HASH( (gint64 *) &i ) ); } else if( generic == G_TYPE_PARAM_INT64 ) { gint64 i = g_value_get_int64( value ); return( INT64_HASH( &i ) ); } else if( generic == G_TYPE_PARAM_FLOAT ) { float f = g_value_get_float( value ); return( g_direct_hash( (void *) &f ) ); } else if( generic == G_TYPE_PARAM_DOUBLE ) { double d = g_value_get_double( value ); return( DOUBLE_HASH( &d ) ); } else if( generic == G_TYPE_PARAM_STRING ) { const char *s = g_value_get_string( value ); return( s ? g_str_hash( s ) : 0 ); } else if( generic == G_TYPE_PARAM_BOXED ) { void *p = g_value_get_boxed( value ); return( p ? g_direct_hash( p ) : 0 ); } else if( generic == G_TYPE_PARAM_POINTER ) { void *p = g_value_get_pointer( value ); return( p ? g_direct_hash( p ) : 0 ); } else if( generic == G_TYPE_PARAM_OBJECT ) { void *p = g_value_get_object( value ); return( p ? g_direct_hash( p ) : 0 ); } else { /* Fallback: convert to a string and hash that. * This is very slow, print a warning if we use it * so we can add another case. */ char *s; unsigned int hash; s = g_strdup_value_contents( value ); hash = g_str_hash( s ); printf( "vips_value_hash: no case for %s\n", s ); printf( "\ttype %d, %s\n", (int) G_VALUE_TYPE( value ), g_type_name( G_VALUE_TYPE( value ) ) ); printf( "\tgeneric %d, %s\n", (int) G_VALUE_TYPE( generic ), g_type_name( generic ) ); g_free( s ); return( hash ); } }