qemu/qobject/qdict.c
/**
 * qdict_put_obj(): Put a new QObject into the dictionary
 *
 * Insert the pair 'key:value' into 'qdict', if 'key' already exists
 * its 'value' will be replaced.
 *
 * This is done by freeing the reference to the stored QObject and
 * storing the new one in the same entry.
 *
 * NOTE: ownership of 'value' is transferred to the QDict
 */


This is done by freeing the reference to the stored QObject and
storing the new one in the same entry.

ownership of 'value' is transferred to the QDict
This is done by freeing the reference to the stored QObject and storing the new one in the same entry . ownership of ' value ' is transferred to the QDict
void qdict_put_obj(QDict *qdict, const char *key, QObject *value)
{
    unsigned int bucket;
    QDictEntry *entry;
    bucket = tdb_hash(key) % QDICT_BUCKET_MAX;
    entry = qdict_find(qdict, key, bucket);
    if (entry) {
        qobject_unref(entry->value);
        entry->value = value;
    } else {
        entry = alloc_entry(key, value);
        QLIST_INSERT_HEAD(&qdict->table[bucket], entry, next);
        qdict->size++;
    }
}
void qdict_put_obj ( QDict * qdict , const char * key , QObject * value ) { unsigned int bucket ; QDictEntry * entry ; bucket = tdb_hash ( key ) % QDICT_BUCKET_MAX ; entry = qdict_find ( qdict , key , bucket ) ; if ( entry ) { qobject_unref ( entry -> value ) ; entry -> value = value ; } else { entry = alloc_entry ( key , value ) ; QLIST_INSERT_HEAD ( & qdict -> table [ bucket ] , entry , next ) ; qdict -> size ++ ; } }
qdict_put_obj(): Put a new QObject into the dictionary
 Insert the pair 'key:value' into 'qdict', if 'key' already exists
 its 'value' will be replaced.
qdict_put_obj () : Put a new QObject into the dictionary Insert the pair ' key : value ' into ' qdict ' if ' key ' already exists its ' value ' will be replaced .
/* replace key's value */ /* allocate a new entry */