Ticket #91 (new defect)

Opened 10 years ago

addMapToMap function

Reported by: Knut Landmark Owned by:
Priority: major Milestone:
Component: zoo-kernel Version:
Keywords: Cc:

Description

The addMapToMap(map** mo, map* mi) function (service.h) should append mi to the last node in mo. However, the function does not work as intended. In the following code fragment, the pointer _cursor is detached from the linked list mo when createMap is called. As a consequence, addMapToMap only modifies mo when *mo == NULL.

   map* _cursor=*mo;
   /* .... */
   while(_cursor!=NULL)
      _cursor=_cursor->next;

   _cursor=createMap(tmp->name,tmp->value);  // _cursor no longer points to node in mo linked list
   _cursor->next=NULL;                       // superfluous

This problem affects, in the least, the support for PHP. See specifically the function map* php_map_from_HasTable(HashTable* t) (service_internal_php.c): The line

   addMapToMap(&final_res, createMap(key,Z_STRVAL(tmpcopy)));

occurs inside a loop over the attributes of an output variable, but a node will only be added to final_res in the first iteration of the loop, i.e. only the first attribute will be included. Thus if the first attribute is not value, the WPS process fails.

I have written a modified addMapToMap function (see below) which resolved the problems with our PHP services (it should be verified independently that the modified function works as required).

 static void addMapToMap( map** mo, map* mi ) {
	
	if ( mo != NULL && mi != NULL ) {
			
		map* p_mi = mi;
		
		if ( *mo == NULL ) {
			*mo = createMap( mi->name, mi->value );
			p_mi = mi->next;
		}
		
		// move to end of *mo linked list
		map* p_mo = *mo;
		while ( p_mo->next != NULL ) { p_mo = p_mo->next; }
		
		// add nodes in mi linked list sequentially
		while ( p_mi != NULL ) {
			p_mo->next = createMap( p_mi->name, p_mi->value );
			p_mi = p_mi->next;
			p_mo = p_mo->next; 
		}	
	}
}
Note: See TracTickets for help on using tickets.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png