Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2125)

Side by Side Diff: src/pkg/debug/dwarf/type.go

Issue 2763041: code review 2763041: use copy (Closed)
Patch Set: code review 2763041: use copy Created 14 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/crypto/x509/x509.go ('k') | src/pkg/debug/macho/file.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // DWARF type information structures. 5 // DWARF type information structures.
6 // The format is heavily biased toward C, but for simplicity 6 // The format is heavily biased toward C, but for simplicity
7 // the String methods use a pseudo-Go syntax. 7 // the String methods use a pseudo-Go syntax.
8 8
9 package dwarf 9 package dwarf
10 10
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 goto Error 447 goto Error
448 } 448 }
449 } 449 }
450 f.Name, _ = kid.Val(AttrName).(string) 450 f.Name, _ = kid.Val(AttrName).(string)
451 f.ByteSize, _ = kid.Val(AttrByteSize).(int64) 451 f.ByteSize, _ = kid.Val(AttrByteSize).(int64)
452 f.BitOffset, _ = kid.Val(AttrBitOffset).(int64) 452 f.BitOffset, _ = kid.Val(AttrBitOffset).(int64)
453 f.BitSize, _ = kid.Val(AttrBitSize).(int64) 453 f.BitSize, _ = kid.Val(AttrBitSize).(int64)
454 n := len(t.Field) 454 n := len(t.Field)
455 if n >= cap(t.Field) { 455 if n >= cap(t.Field) {
456 fld := make([]*StructField, n, n*2) 456 fld := make([]*StructField, n, n*2)
457 » » » » » for i, f := range t.Field { 457 » » » » » copy(fld, t.Field)
458 » » » » » » fld[i] = f
459 » » » » » }
460 t.Field = fld 458 t.Field = fld
461 } 459 }
462 t.Field = t.Field[0 : n+1] 460 t.Field = t.Field[0 : n+1]
463 t.Field[n] = f 461 t.Field[n] = f
464 } 462 }
465 } 463 }
466 464
467 case TagConstType, TagVolatileType, TagRestrictType: 465 case TagConstType, TagVolatileType, TagRestrictType:
468 // Type modifier (DWARF v2 §5.2) 466 // Type modifier (DWARF v2 §5.2)
469 // Attributes: 467 // Attributes:
(...skipping 28 matching lines...) Expand all
498 t.EnumName, _ = e.Val(AttrName).(string) 496 t.EnumName, _ = e.Val(AttrName).(string)
499 t.Val = make([]*EnumValue, 0, 8) 497 t.Val = make([]*EnumValue, 0, 8)
500 for kid := next(); kid != nil; kid = next() { 498 for kid := next(); kid != nil; kid = next() {
501 if kid.Tag == TagEnumerator { 499 if kid.Tag == TagEnumerator {
502 f := new(EnumValue) 500 f := new(EnumValue)
503 f.Name, _ = kid.Val(AttrName).(string) 501 f.Name, _ = kid.Val(AttrName).(string)
504 f.Val, _ = kid.Val(AttrConstValue).(int64) 502 f.Val, _ = kid.Val(AttrConstValue).(int64)
505 n := len(t.Val) 503 n := len(t.Val)
506 if n >= cap(t.Val) { 504 if n >= cap(t.Val) {
507 val := make([]*EnumValue, n, n*2) 505 val := make([]*EnumValue, n, n*2)
508 » » » » » for i, f := range t.Val { 506 » » » » » copy(val, t.Val)
509 » » » » » » val[i] = f
510 » » » » » }
511 t.Val = val 507 t.Val = val
512 } 508 }
513 t.Val = t.Val[0 : n+1] 509 t.Val = t.Val[0 : n+1]
514 t.Val[n] = f 510 t.Val[n] = f
515 } 511 }
516 } 512 }
517 513
518 case TagPointerType: 514 case TagPointerType:
519 // Type modifier (DWARF v2 §5.2) 515 // Type modifier (DWARF v2 §5.2)
520 // Attributes: 516 // Attributes:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 case TagFormalParameter: 550 case TagFormalParameter:
555 if tkid = typeOf(kid); err != nil { 551 if tkid = typeOf(kid); err != nil {
556 goto Error 552 goto Error
557 } 553 }
558 case TagUnspecifiedParameters: 554 case TagUnspecifiedParameters:
559 tkid = &DotDotDotType{} 555 tkid = &DotDotDotType{}
560 } 556 }
561 n := len(t.ParamType) 557 n := len(t.ParamType)
562 if n >= cap(t.ParamType) { 558 if n >= cap(t.ParamType) {
563 param := make([]Type, n, n*2) 559 param := make([]Type, n, n*2)
564 » » » » for i, t := range t.ParamType { 560 » » » » copy(param, t.ParamType)
565 » » » » » param[i] = t
566 » » » » }
567 t.ParamType = param 561 t.ParamType = param
568 } 562 }
569 t.ParamType = t.ParamType[0 : n+1] 563 t.ParamType = t.ParamType[0 : n+1]
570 t.ParamType[n] = tkid 564 t.ParamType[n] = tkid
571 } 565 }
572 566
573 case TagTypedef: 567 case TagTypedef:
574 // Typedef (DWARF v2 §5.3) 568 // Typedef (DWARF v2 §5.3)
575 // Attributes: 569 // Attributes:
576 // AttrName: name [required] 570 // AttrName: name [required]
(...skipping 17 matching lines...) Expand all
594 588
595 return typ, nil 589 return typ, nil
596 590
597 Error: 591 Error:
598 // If the parse fails, take the type out of the cache 592 // If the parse fails, take the type out of the cache
599 // so that the next call with this offset doesn't hit 593 // so that the next call with this offset doesn't hit
600 // the cache and return success. 594 // the cache and return success.
601 d.typeCache[off] = nil, false 595 d.typeCache[off] = nil, false
602 return nil, err 596 return nil, err
603 } 597 }
OLDNEW
« no previous file with comments | « src/pkg/crypto/x509/x509.go ('k') | src/pkg/debug/macho/file.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b