RFG_RegionInfo* RFG_Regions_add( RFG_Regions* regions,
				 const char* rname, uint32_t rid )
{
  RFG_RegionInfo* rinf;
  char*    gname;
  int32_t  climit;

  if( !regions ) return NULL;

  if( !rname )
  {
    fprintf( stderr, "RFG_Regions_add(): Error: Empty region name\n" );
    return NULL;
  }

  /* look for already existing hash node of this region */

  rinf = hash_get( regions->htab, rid );
  if( !rinf )
  {
    /* get group information of this region */

    if( !RFG_Groups_get( regions->groups, rname, &gname ) )
      return NULL;

    /* get filter information of this region */

    if( !RFG_Filter_get( regions->filter, rname, &climit ) )
      return NULL;

    /* add region information to hash table */

    hash_put( regions->htab,
	      rid,
	      gname,
	      rname,
	      climit );

    rinf = hash_get( regions->htab, rid );
  }

  return rinf;
}
RFG_RegionInfo* RFG_Regions_add( RFG_Regions* regions, uint32_t regionId,
                                 const char* regionName,
                                 const char* defaultGroupName )
{
  RFG_RegionInfoHN* region_info_hn;

  if( !regions )
    return NULL;

  if( !regionName || *regionName == '\0' )
  {
    fprintf( stderr, "RFG_Regions_add(): Error: Empty region name\n" );
    return NULL;
  }

  if( !defaultGroupName || *defaultGroupName == '\0' )
  {
    fprintf( stderr, "RFG_Regions_add(): Error: Empty default group name\n" );
    return NULL;
  }

  /* look for an already existing region info */
  region_info_hn = region_info_hash_get( regions->region_infos, regionId );

  /* create a new one, if not exist */

  if( !region_info_hn )
  {
    char*    group_name = NULL;
    int32_t  call_limit;
    uint32_t stack_bounds[2];
    uint8_t  flags;

    /* get group information of this region */

    if( !RFG_Groups_get( regions->groups, regionName, &group_name ) )
      return NULL;

    /* set group name to given default, if no group information present */

    if( !group_name )
      group_name = (char*)defaultGroupName;

    /* get filter information of this region */

    if( !RFG_Filter_getRegionRules( regions->filter, regionName, group_name,
          &call_limit, stack_bounds, &flags ) )
    {
      return NULL;
    }

    /* add region info to hash table */

    region_info_hn =
      region_info_hash_put( regions->region_infos, regionId, regionName,
        group_name, call_limit, stack_bounds, flags );
    regions->num_region_infos++;
  }

  return &(region_info_hn->info);
}