Index: gdbtypes.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtypes.c,v retrieving revision 1.41 diff -p -r1.41 gdbtypes.c *** gdbtypes.c 2002/02/08 17:34:33 1.41 --- gdbtypes.c 2002/02/22 11:30:14 *************** alloc_type (struct objfile *objfile) *** 155,160 **** --- 155,177 ---- return (type); } + /* Reset the memory of a type structure. */ + struct type * + realloc_type (struct type *type, struct objfile *objfile) + { + memset ((char *) type, 0, sizeof (struct type)); + + /* Initialize the fields that might not be zero. */ + + TYPE_CODE (type) = TYPE_CODE_UNDEF; + TYPE_OBJFILE (type) = objfile; + TYPE_VPTR_FIELDNO (type) = -1; + TYPE_CV_TYPE (type) = type; /* chain back to itself */ + TYPE_AS_TYPE (type) = type; /* ditto */ + + return (type); + } + /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points to a pointer to memory where the pointer type should be stored. If *TYPEPTR is zero, update it to point to the pointer type we return. *************** make_pointer_type (struct type *type, st *** 190,197 **** { ntype = *typeptr; objfile = TYPE_OBJFILE (ntype); ! memset ((char *) ntype, 0, sizeof (struct type)); ! TYPE_OBJFILE (ntype) = objfile; } TYPE_TARGET_TYPE (ntype) = type; --- 207,213 ---- { ntype = *typeptr; objfile = TYPE_OBJFILE (ntype); ! realloc_type (ntype, objfile); } TYPE_TARGET_TYPE (ntype) = type; *************** make_reference_type (struct type *type, *** 257,264 **** { ntype = *typeptr; objfile = TYPE_OBJFILE (ntype); ! memset ((char *) ntype, 0, sizeof (struct type)); ! TYPE_OBJFILE (ntype) = objfile; } TYPE_TARGET_TYPE (ntype) = type; --- 273,279 ---- { ntype = *typeptr; objfile = TYPE_OBJFILE (ntype); ! realloc_type (ntype, objfile); } TYPE_TARGET_TYPE (ntype) = type; *************** make_function_type (struct type *type, s *** 306,313 **** { ntype = *typeptr; objfile = TYPE_OBJFILE (ntype); ! memset ((char *) ntype, 0, sizeof (struct type)); ! TYPE_OBJFILE (ntype) = objfile; } TYPE_TARGET_TYPE (ntype) = type; --- 321,327 ---- { ntype = *typeptr; objfile = TYPE_OBJFILE (ntype); ! realloc_type (ntype, objfile); } TYPE_TARGET_TYPE (ntype) = type; *************** make_cv_type (int cnst, int voltl, struc *** 413,421 **** register struct type *tmp_type = type; /* tmp type */ struct objfile *objfile; ! ntype = TYPE_CV_TYPE (type); ! while (ntype != type) { if ((TYPE_CONST (ntype) == cnst) && (TYPE_VOLATILE (ntype) == voltl)) --- 427,435 ---- register struct type *tmp_type = type; /* tmp type */ struct objfile *objfile; ! ntype = type; ! do { if ((TYPE_CONST (ntype) == cnst) && (TYPE_VOLATILE (ntype) == voltl)) *************** make_cv_type (int cnst, int voltl, struc *** 428,436 **** --- 442,462 ---- return ntype; } } + + /* We have storage and it matches something already in this type. We + must update it. */ + if (typeptr && *typeptr == ntype) + { + /* Remove this from the chain (so that we can put it back again + below). */ + TYPE_CV_TYPE (tmp_type) = TYPE_CV_TYPE (ntype); + break; + } + tmp_type = ntype; ntype = TYPE_CV_TYPE (ntype); } + while (ntype != type); if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ { *************** make_cv_type (int cnst, int voltl, struc *** 467,473 **** TYPE_FLAGS (ntype) &= ~TYPE_FLAG_VOLATILE; /* Fix the chain of cv variants */ ! TYPE_CV_TYPE (ntype) = type; TYPE_CV_TYPE (tmp_type) = ntype; return ntype; --- 493,499 ---- TYPE_FLAGS (ntype) &= ~TYPE_FLAG_VOLATILE; /* Fix the chain of cv variants */ ! TYPE_CV_TYPE (ntype) = TYPE_CV_TYPE (tmp_type); TYPE_CV_TYPE (tmp_type) = ntype; return ntype; *************** smash_to_member_type (struct type *type, *** 877,884 **** objfile = TYPE_OBJFILE (type); ! memset ((char *) type, 0, sizeof (struct type)); ! TYPE_OBJFILE (type) = objfile; TYPE_TARGET_TYPE (type) = to_type; TYPE_DOMAIN_TYPE (type) = domain; TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ --- 903,909 ---- objfile = TYPE_OBJFILE (type); ! realloc_type (type, objfile); TYPE_TARGET_TYPE (type) = to_type; TYPE_DOMAIN_TYPE (type) = domain; TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ *************** smash_to_method_type (struct type *type, *** 900,907 **** objfile = TYPE_OBJFILE (type); ! memset ((char *) type, 0, sizeof (struct type)); ! TYPE_OBJFILE (type) = objfile; TYPE_TARGET_TYPE (type) = to_type; TYPE_DOMAIN_TYPE (type) = domain; TYPE_ARG_TYPES (type) = args; --- 925,931 ---- objfile = TYPE_OBJFILE (type); ! realloc_type (type, objfile); TYPE_TARGET_TYPE (type) = to_type; TYPE_DOMAIN_TYPE (type) = domain; TYPE_ARG_TYPES (type) = args;