duplicating a  GHashTable

Posted on 2005-05-13
Last Modified: 2008-01-09
Hi i want to create a  GHashTable  from an existing GHashTable
my need is to create a temproery GHashTable for some purpose
i looked here
but i didnt find any easier way

void fff(GHashTable *gp)
GHashTable tmpg;
tmpg=make_new _ghashtable(gp);
i want to do like this ,is ther any simple way like this or ,i need to access each strings in the existing ghashtable and need to insert into tmp hashtable?

Question by:hirosh
    1 Comment
    LVL 12

    Accepted Solution

    Hi hirosh,
    There's no direct copy function. You need to use the g_hash_table_foreach() to iterate over the old table to create a copy of it.

    Example (haven't tested it):

    void copy_hash_table(GHashTable *dest, GHashTable *src){

    static void copy_hash_table_iterator(gpointer key,gpointer val, gpointer dest){
        g_hash_table_insert((GHashTable*) dest, key,val);

    (this assumes the dest table is empty when passed)



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now