Subject: [Dev] An STL challenge

From: "M. Mueller (bhu5nji)" <[email-masked]>
Date: Tue, 12 Mar 2002 01:03:46 -0500

Can you find out why the following code executes the "fatal" line below?  
Even though the program segments are incomplete, there is enough information 
supplied to locate the the reason.

Enjoy.

Here are the declarations.......

// Route Availability Table declarations

typedef struct {
	uint8_t		pf PACKED;
	uint8_t		cls PACKED;
	uint8_t		b1 PACKED;
	uint8_t		b2 PACKED;
} t_rtAvail_key_components;

typedef struct {
	union {
		t_rtAvail_key_components	key_components;
		uint32_t			key;
	} u_rtAvail_key;
} t_rtAvail_key;

typedef struct {
	e_yes_no	ls_available[MAX_LINKS_IN_MTP3_LINKSET];
} t_rtAvailable_entry;

typedef map<uint32_t, t_rtAvailable_entry> t_routeAvailableTable;

-------------------------------------------------------------------------------------------------
here's where the map is loaded......

		// make a Route Availability Table entry for this
		// combination of PF + CLS if one has not been made already

		t_rtAvail_key		rtAvail_key;
		// make key
		rtAvail_key.u_rtAvail_key.key_components.pf = pf;
		rtAvail_key.u_rtAvail_key.key_components.cls = cls;
		// try to find this key in the table
		if (routeAvailTable.find(rtAvail_key.u_rtAvail_key.key) == 
routeAvailTable.end())
		{
			t_rtAvailable_entry	rtAvail_entry;
			rtAvail_entry.ls_available[0] = NO;
			rtAvail_entry.ls_available[1] = NO;
			routeAvailTable[rtAvail_key.u_rtAvail_key.key] = rtAvail_entry;
		}
-------------------------------------------------------------------------------------------------
here's where the map is used.....

			t_rtAvail_key		rtAvail_key;
			// make key
			rtAvail_key.u_rtAvail_key.key_components.pf = PF_MTP3;
			rtAvail_key.u_rtAvail_key.key_components.cls = 
				p_pdimb->mhdr.src.cls;
			// try to find this key in the table
			t_routeAvailableTable::iterator ra_i;
			ra_i = routeAvailTable.find(rtAvail_key.u_rtAvail_key.key);
			if (ra_i == routeAvailTable.end())
			{
				fatal (
	"processMsgFromMtp3:PATH_AVAILBLE/UNAVAILABLE", "Route not in table", 0);
			}
			else (* ra_i).second.ls_available[p_pdimb->mhdr.src.ls] = 
				p_pdimb->mhdr.f_id == PATH_AVAILABLE ? YES : NO;
			}

-- 
Mike  M.

Support TriLUG. Reply directly for details on how to send a check.
No amount is too small.

Subscribe to all the TriLUG lists at http://trilug.org/mailman/listinfo