void kvp_frame_add_frame_nc(KvpFrame * frame, const char * path, KvpFrame *fr) { KvpValue *value; value = kvp_value_new_frame_nc (fr); frame = kvp_frame_add_value_nc (frame, path, value); if (!frame) kvp_value_delete (value); }
/* Get the named frame, or create it if it doesn't exist. * gcc -O3 should inline it. It performs no error checks, * the caller is responsible of passing good keys and frames. */ static inline KvpFrame * get_or_make (KvpFrame *fr, const char * key) { KvpFrame *next_frame; KvpValue *value; value = kvp_frame_get_slot (fr, key); if (value) { next_frame = kvp_value_get_frame (value); } else { next_frame = kvp_frame_new (); kvp_frame_set_slot_nc (fr, key, kvp_value_new_frame_nc (next_frame)); } return next_frame; }
static void set_guid_val( gpointer pObject, /*@ null @*/ gpointer pValue ) { slot_info_t* pInfo = (slot_info_t*)pObject; g_return_if_fail( pObject != NULL ); if ( pValue == NULL ) return; switch ( pInfo->value_type) { case KVP_TYPE_GUID: { KvpValue *value = kvp_value_new_guid( (GncGUID*)pValue ); set_slot_from_value( pInfo, value ); break; } case KVP_TYPE_GLIST: { slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue ); kvp_value *pValue = NULL; gchar *key = get_key_from_path( pInfo->path ); newInfo->context = LIST; slots_load_info( newInfo ); pValue = kvp_value_new_glist_nc( newInfo->pList ); kvp_frame_set_slot_nc(pInfo->pKvpFrame, key, pValue); g_string_free( newInfo->path, TRUE ); g_slice_free( slot_info_t, newInfo ); g_free( key ); break; } case KVP_TYPE_FRAME: { slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue ) ; KvpFrame *newFrame = kvp_frame_new(); newInfo->pKvpFrame = newFrame; switch ( pInfo->context ) { case LIST: { KvpValue *value = kvp_value_new_frame_nc( newFrame ); gchar *key = get_key_from_path( pInfo->path ); newInfo->path = g_string_assign( newInfo->path, key ); pInfo->pList = g_list_append( pInfo->pList, value ); g_free( key ); break; } case FRAME: default: { gchar *key = get_key_from_path( pInfo->path ); kvp_frame_set_frame_nc( pInfo->pKvpFrame, key, newFrame ); g_free( key ); break; } } newInfo->context = FRAME; slots_load_info ( newInfo ); g_string_free( newInfo->path, TRUE ); g_slice_free( slot_info_t, newInfo ); break; } default: break; } }