src/libs/elektra/keyset.c
/**
 * @internal
 * @brief Helper for elektraLookupBySpec
 *
 * Lookup using links (fallback or override passed as buffer)
 *
 * @param ks the keyset to search in
 * @param specKey contains metadata as specified in buffer+#<number>
 * @param buffer the buffer used for incrementing numbers
 *
 * @return
 */
@internal
@brief Helper for elektraLookupBySpec

Lookup using links (fallback or override passed as buffer)

@param ks the keyset to search in
@param specKey contains metadata as specified in buffer+#
@param buffer the buffer used for incrementing numbers

@return
@internal @brief Helper for elektraLookupBySpec Lookup using links ( fallback or override passed as buffer ) @param ks the keyset to search in @param specKey contains metadata as specified in buffer + # @param buffer the buffer used for incrementing numbers @return
static Key * elektraLookupBySpecLinks (KeySet * ks, Key * specKey, char * buffer)
{
	Key * ret = 0;
	Key * k = 0;
	const int prefixSize = ELEKTRA_MAX_PREFIX_SIZE - 2;
	kdb_long_long_t i = 0;
	const Key * m = 0;
	do
	{
		elektraWriteArrayNumber (&buffer[prefixSize], i);
		m = keyGetMeta (specKey, buffer);
		if (!m) break;
		if (!k)
		{
			k = keyNew (keyString (m), KEY_CASCADING_NAME, KEY_END);
			keySetBinary (k, keyValue (specKey), keyGetValueSize (specKey));
			elektraCopyCallbackMeta (k, specKey);
		}
		else
			elektraKeySetName (k, keyString (m), KEY_CASCADING_NAME);
		ret = ksLookup (ks, k, KDB_O_NODEFAULT);
		if (ret) break;
		++i;
	} while (m);
	if (k)
	{
		elektraCopyCallbackMeta (specKey, k);
		keyDel (k);
	}
	return ret;
}
static Key * elektraLookupBySpecLinks ( KeySet * ks , Key * specKey , char * buffer ) { Key * ret = 0 ; Key * k = 0 ; const int prefixSize = ELEKTRA_MAX_PREFIX_SIZE - 2 ; kdb_long_long_t i = 0 ; const Key * m = 0 ; do { elektraWriteArrayNumber ( & buffer [ prefixSize ] , i ) ; m = keyGetMeta ( specKey , buffer ) ; if ( ! m ) break ; if ( ! k ) { k = keyNew ( keyString ( m ) , KEY_CASCADING_NAME , KEY_END ) ; keySetBinary ( k , keyValue ( specKey ) , keyGetValueSize ( specKey ) ) ; elektraCopyCallbackMeta ( k , specKey ) ; } else elektraKeySetName ( k , keyString ( m ) , KEY_CASCADING_NAME ) ; ret = ksLookup ( ks , k , KDB_O_NODEFAULT ) ; if ( ret ) break ; ++ i ; } while ( m ) ; if ( k ) { elektraCopyCallbackMeta ( specKey , k ) ; keyDel ( k ) ; } return ret ; }
@internal
 @brief Helper for elektraLookupBySpec
@internal @brief Helper for elektraLookupBySpec
// optimization: lazy instanziation of k