WinDBG/Exts/CodeAnalyzer/gdbplus/gdb-7.7/gdb/gdb_dep.c
// return false if the address is already in the map, or invalid params
return false if the address is already in the map, or invalid params
return false if the address is already in the map or invalid params
static CA_BOOL
add_addr_type(address_t addr, struct type* type, struct symbol* sym)
{
	int i;
	if (sym)
		type = SYMBOL_TYPE(sym);
	if (!type)
		return CA_FALSE;
	CHECK_TYPEDEF(type);
	if (TYPE_CODE(type) == TYPE_CODE_PTR || TYPE_CODE(type) == TYPE_CODE_REF)
		type = TYPE_TARGET_TYPE (type);
	for (i = addr_type_map_sz - 1; i >= 0; i--)
	{
		if (addr >= addr_type_map[i].addr && addr + TYPE_LENGTH(type) <= addr_type_map[i].addr + addr_type_map[i].size)
			return CA_TRUE;
		else if (addr_type_map[i].addr >= addr && addr_type_map[i].addr + addr_type_map[i].size <= addr + TYPE_LENGTH(type))
		{
			addr_type_map[i].addr = addr;
			addr_type_map[i].type = type;
			addr_type_map[i].sym  = sym;
			addr_type_map[i].size = TYPE_LENGTH(type);
			return CA_TRUE;
		}
	}
	if (addr_type_map_sz >= addr_type_map_buf_sz)
	{
		if (addr_type_map_buf_sz == 0)
			addr_type_map_buf_sz = 64;
		else
			addr_type_map_buf_sz = addr_type_map_buf_sz * 2;
		addr_type_map = realloc(addr_type_map, addr_type_map_buf_sz * sizeof(struct ca_addr_type_pair));
	}
	addr_type_map[addr_type_map_sz].addr = addr;
	addr_type_map[addr_type_map_sz].type = type;
	addr_type_map[addr_type_map_sz].sym = sym;
	addr_type_map[addr_type_map_sz].size = TYPE_LENGTH(type);
	addr_type_map_sz++;
	return CA_TRUE;
}
static CA_BOOL add_addr_type ( address_t addr , struct type * type , struct symbol * sym ) { int i ; if ( sym ) type = SYMBOL_TYPE ( sym ) ; if ( ! type ) return CA_FALSE ; CHECK_TYPEDEF ( type ) ; if ( TYPE_CODE ( type ) == TYPE_CODE_PTR || TYPE_CODE ( type ) == TYPE_CODE_REF ) type = TYPE_TARGET_TYPE ( type ) ; for ( i = addr_type_map_sz - 1 ; i >= 0 ; i -- ) { if ( addr >= addr_type_map [ i ] . addr && addr + TYPE_LENGTH ( type ) <= addr_type_map [ i ] . addr + addr_type_map [ i ] . size ) return CA_TRUE ; else if ( addr_type_map [ i ] . addr >= addr && addr_type_map [ i ] . addr + addr_type_map [ i ] . size <= addr + TYPE_LENGTH ( type ) ) { addr_type_map [ i ] . addr = addr ; addr_type_map [ i ] . type = type ; addr_type_map [ i ] . sym = sym ; addr_type_map [ i ] . size = TYPE_LENGTH ( type ) ; return CA_TRUE ; } } if ( addr_type_map_sz >= addr_type_map_buf_sz ) { if ( addr_type_map_buf_sz == 0 ) addr_type_map_buf_sz = 64 ; else addr_type_map_buf_sz = addr_type_map_buf_sz * 2 ; addr_type_map = realloc ( addr_type_map , addr_type_map_buf_sz * sizeof ( struct ca_addr_type_pair ) ) ; } addr_type_map [ addr_type_map_sz ] . addr = addr ; addr_type_map [ addr_type_map_sz ] . type = type ; addr_type_map [ addr_type_map_sz ] . sym = sym ; addr_type_map [ addr_type_map_sz ] . size = TYPE_LENGTH ( type ) ; addr_type_map_sz ++ ; return CA_TRUE ; }
return false if the address is already in the map, or invalid params
return false if the address is already in the map or invalid params
// check duplicate entry // The new type is the sub-type of an existing one // The new type is the super-type of an existing one // expand buffer if necessary // append the newly-discovered type