Jan,

I have written this code, in which in main()  an HXmap is created, its address passed to the function MessageProcess() (along with other necessary stuff), MessageProcess() does certain things inside it, basically makes some decisions, if for a given key, data is not there in the map then it will add the data etc. When I come back to main(), given the same key, I am not able to retrieve it. Though using the same piece of code, I am able to retrieve it inside MessageProcess() which means, my addition of the data did happen. I checked the address of the HXmaps as well, they do match. Please take a look

//Process Messages
void MessageProcess(Message *newMessage,HXmap* AssetMap)
{

    Order* newOrder = (Order*)malloc(sizeof(Order));
    Asset* asset;
    Asset* Check;
    Limit* limit;
    switch(newMessage->type)
    {
    case 'N':
           
            newOrder =Order_Init(newMessage->idNum,newMessage->BS,newMessage->shares1,newMessage->price1,newMessage->Time,NULL);//create a new order;
            asset = HXmap_get(AssetMap,&newMessage->asset);        //does the asset exist?
        if(asset==NULL)
        {
            asset = Asset_Init();            //if no create  asset
              HXmap_add(AssetMap,&newMessage->asset,asset);   
                Check = HXmap_get(AssetMap,&newMessage->asset);
            printf("Check: %p \n",Check);   
        }
   
        limit=HXmap_get(asset->OrderBook->LimitMap,&newOrder->limitPrice);//does the limit exist,
   
        if(limit==NULL)
        {
   
        //    if no create and add  limit
        limit = Limit_init(newOrder->limitPrice);
   
            if(newOrder->BuySell)   
            asset->OrderBook->buyTree= AddLimit(asset->OrderBook->buyTree,limit,asset->OrderBook->LimitMap);   
            else
            asset->OrderBook->sellTree= AddLimit(asset->OrderBook->sellTree,limit,asset->OrderBook->LimitMap);   
        }   
        //add order
    AddOrder(newOrder,limit,asset->OrderBook->OrderMap);
        break;

        case 'M':
        //create the order
        //call modifyorder
        break;

        case 'X':
        //create the order
        //call cancelorder
        break;

        case 'T':
        //create the order
        //call tradeorder;
        break;
    }
}
int main()
{
    HXmap* AssetMap =  HXmap_init5(HXMAPT_DEFAULT,HXMAP_CKEY,NULL,256,0);
    Message* newMessage= (Message*)malloc(sizeof(Message));
    parser("N,8545,01/02/2011 09:15:01.815,\"RASTA OPTSTK 24FEB2011 1,150.00 CE\",S,8.80,250,0.00,0",newMessage);
    printf("AssetName: %s\n",newMessage->asset);
    MessageProcess(newMessage,AssetMap);
    Asset* Check;
    Check =(Asset*) HXmap_get(AssetMap,&newMessage->asset);
    printf("Check: %p\n",Check);

    return 0;

}

Thanks for your valuable time and mental bandwidth :)

Soham

On 13 February 2011 19:23, Soham Das <sohamdas@gmail.com> wrote:
Thanks. I corrected it.
Much appreciated.

Soham


On 13 February 2011 18:03, Jan Engelhardt <jengelh@medozas.de> wrote:

On Sunday 2011-02-13 13:30, Jan Engelhardt wrote:
>On Sunday 2011-02-13 06:23, Soham Das wrote:
>
>>int main()
>>{
>>        int a[]={1,2,3};
>>        HXmap_add(limitMap,a,limitMap);
>>}
>
>If you use key copying (HXMAP_CKEY), you need to specify how large
>the key actually is - when it is not a string (HXMAP_SKEY).
>I will be adding a patch to the library to emit a warning to
>catch this case.
>
>What you would need for your code is
>
>       HXmap_init5(HXMAPT_DEFAULT, HXMAP_CKEY, NULL, sizeof(int *), 0);

This should have been just sizeof(int).