Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
f5e15221
Commit
f5e15221
authored
16 years ago
by
edgrif
Browse files
Options
Downloads
Patches
Plain Diff
add print func for hashlist package + fix bad bug when inserting.
parent
9efbd646
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/ZMap/zmapGLibUtils.h
+3
-3
3 additions, 3 deletions
src/include/ZMap/zmapGLibUtils.h
src/zmapUtils/zmapGLibUtils.c
+37
-3
37 additions, 3 deletions
src/zmapUtils/zmapGLibUtils.c
with
40 additions
and
6 deletions
src/include/ZMap/zmapGLibUtils.h
+
3
−
3
View file @
f5e15221
...
...
@@ -26,9 +26,9 @@
* glib but not included with their distribution.
*
* HISTORY:
* Last edited: Apr
16 08
:5
2
2009 (edgrif)
* Last edited: Apr
22 11
:5
1
2009 (edgrif)
* Created: Thu Oct 13 15:56:54 2005 (edgrif)
* CVS info: $Id: zmapGLibUtils.h,v 1.2
0
2009-04-
16 09:05:19
edgrif Exp $
* CVS info: $Id: zmapGLibUtils.h,v 1.2
1
2009-04-
22 16:25:00
edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_GLIBUTILS_H
...
...
@@ -86,8 +86,8 @@ GHashTable *zMap_g_hashlist_create(void) ;
gboolean
zMap_g_string_replace
(
GString
*
string
,
char
*
target
,
char
*
source
)
;
void
zMap_g_hashlist_insert
(
GHashTable
*
hashlist
,
GQuark
key
,
gpointer
value
)
;
void
zMap_g_hashlist_insert
(
GHashTable
*
hashlsit
,
GQuark
key
,
gpointer
value
)
;
GHashTable
*
zMap_g_hashlist_copy
(
GHashTable
*
orig_hashlist
)
;
void
zMap_g_hashlist_print
(
GHashTable
*
hashlist
)
;
void
zMap_g_hashlist_destroy
(
GHashTable
*
hashlist
)
;
...
...
This diff is collapsed.
Click to expand it.
src/zmapUtils/zmapGLibUtils.c
+
37
−
3
View file @
f5e15221
...
...
@@ -26,9 +26,9 @@
*
* Exported functions: See ZMap/zmapGLibUtils.h
* HISTORY:
* Last edited: Apr
16 08:54
2009 (edgrif)
* Last edited: Apr
22 17:23
2009 (edgrif)
* Created: Thu Oct 13 15:22:35 2005 (edgrif)
* CVS info: $Id: zmapGLibUtils.c,v 1.2
7
2009-04-
16 09:05:19
edgrif Exp $
* CVS info: $Id: zmapGLibUtils.c,v 1.2
8
2009-04-
22 16:25:00
edgrif Exp $
*-------------------------------------------------------------------
*/
...
...
@@ -83,6 +83,7 @@ static void get_first_datalist_key(GQuark id, gpointer data, gpointer user_data)
static
gboolean
getNthHashElement
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
;
static
void
hashCopyListCB
(
gpointer
key
,
gpointer
value
,
gpointer
user_data
)
;
static
void
hashPrintListCB
(
gpointer
key
,
gpointer
value
,
gpointer
user_data_unused
)
;
static
void
destroyList
(
gpointer
data
)
;
...
...
@@ -519,6 +520,12 @@ gpointer zMap_g_hash_table_nth(GHashTable *hash_table, int nth)
* construct and look at his list hence these functions.
*
* Copy function could easily be extended to allow deep list copying with a callback.
*
* NOTE WELL: There is a destroy function for the hash values and this WILL get
* called by g_hash_table for inserts/replaces. Below you will see we copy lists
* because as soon as we reinsert the list the old copy will be deleted by the
* delete callback.
*
* */
...
...
@@ -540,9 +547,13 @@ void zMap_g_hashlist_insert(GHashTable *hashlist, GQuark key, gpointer value)
/* Slightly tricky coding, if we don't find a list the append creates a new list,
* otherwise we append to the existing list. Either way we then _always_ replace
* the list in the hash as list start in theory could change. */
* the list in the hash as list start in theory could change. BUT note that
* we must copy the list before we insert it because otherwise it is erased
* by g_hash_table calling the existing entries delete function. */
list
=
(
GList
*
)
g_hash_table_lookup
(
hashlist
,
GINT_TO_POINTER
(
key
))
;
list
=
g_list_copy
(
list
)
;
list
=
g_list_append
(
list
,
value
)
;
g_hash_table_insert
(
hashlist
,
GINT_TO_POINTER
(
key
),
list
)
;
...
...
@@ -564,6 +575,15 @@ GHashTable *zMap_g_hashlist_copy(GHashTable *orig_hashlist)
}
/*! Print out the featureset -> styles lists. */
void
zMap_g_hashlist_print
(
GHashTable
*
hashlist
)
{
g_hash_table_foreach
(
hashlist
,
hashPrintListCB
,
NULL
)
;
return
;
}
void
zMap_g_hashlist_destroy
(
GHashTable
*
hashlist
)
{
g_hash_table_destroy
(
hashlist
)
;
...
...
@@ -944,6 +964,20 @@ static void hashCopyListCB(gpointer key, gpointer value, gpointer user_data)
/* A GHFunc() to print the list attached to a hash entry. */
static
void
hashPrintListCB
(
gpointer
key
,
gpointer
value
,
gpointer
user_data_unused
)
{
GList
*
styles_list
=
(
GList
*
)
value
;
printf
(
"
\"
%s
\"
: "
,
g_quark_to_string
(
GPOINTER_TO_INT
(
key
)))
;
zMap_g_list_quark_print
(
styles_list
,
"Styles"
,
FALSE
)
;
return
;
}
/* A GDestroyNotify() to free Glists held as the data in a hash. */
static
void
destroyList
(
gpointer
data
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment