//-----------------------------------------------------------------------------
// Copyright © 2003 - Philip Howard - All rights reserved
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//-----------------------------------------------------------------------------
// package	libh/map
// homepage	http://libh.slashusr.org/
//-----------------------------------------------------------------------------
// author	Philip Howard
// email	libh at ipal dot org
// homepage	http://phil.ipal.org/
//-----------------------------------------------------------------------------
// This file is best viewed using a fixed spaced font such as Courier
// and in a display at least 112 columns wide.
//-----------------------------------------------------------------------------

#include "map_lib.h"

//-----------------------------------------------------------------------------
// struct       map_link_slla
// struct       map_node_slla
//
// purpose      Define structures needed to keep the AVL trees used to hold
//              a mapping of this particular key type.
//
// note		The key array size is determined when node is created.
//-----------------------------------------------------------------------------
struct map_link_slla {
    avl_link		link    ;
    size_t		keylen	;
    signed long long		key	[1];
};

struct map_node_slla {
    struct map_mixed		data    ;
    struct map_link_slla	link    ;
};

//-----------------------------------------------------------------------------
// function	map_slla_length (internal, inline)
//
// purpose	Determine the length of a string of this key or data type.
//
// arguments	1 (const signed long long *) string pointer
//
// returns	(size_t) length of string
//-----------------------------------------------------------------------------
inline static
size_t
map_slla_length (
    const signed long long *	arg_str
    )
{
    size_t	len	;
    len = 0;
    while ( * arg_str ++ != (signed long long) 0 ) ++ len;
    return len;
}

//-----------------------------------------------------------------------------
// function	map_slla_copy_array (internal, inline)
//
// purpose	Copy a string of this key or data type, and terminate it.
//
// arguments	1 (signed long long *) destination pointer
//		2 (const signed long long *) source pointer
//		3 (size_t) length to copy
//
// returns	(void) nothing
//-----------------------------------------------------------------------------
inline static
void
map_slla_copy_array (
    signed long long *		arg_dst
    ,
    const signed long long *	arg_src
    ,
    size_t		arg_len
    )
{
    while ( arg_len -- ) * arg_dst ++ = * arg_src ++;
    * arg_dst = (signed long long) 0;
    return;
}


