deep-copy
deep-copy copied to clipboard
Tool doesn't handle fixed size arrays at all
When you try to deep-copy the follwing code
package main
type s3 struct {
Y int
Z int
}
type s2 struct {
X int
String *byte
Ps3 *s3
}
type s1 struct {
ArrayOfS2 [10]s2
ArrayOfPointerS2 [20]*s2
PInt *int
}
then the arrays are simply ommitted...
// generated by /home/ubuntu/go/bin/deep-copy --type s1 build/golang_converted.go; DO NOT EDIT.
package main
// DeepCopy generates a deep copy of s1
func (o s1) DeepCopy() s1 {
var cp s1 = o
if o.PInt != nil {
cp.PInt = new(int)
*cp.PInt = *o.PInt
}
return cp
}
exact command used:
~/go/bin/deep-copy --type s1 arrayStruct.h
From my understanding fixed size arrays are always copied by value.
See https://go.dev/play/p/yapKWLrehlPv
So var cp s1 = o is enough.
Ok probably ArrayOfPointerS2 needs to be handled.
Indeed, the arrays being omitted should be fine. What should not be is omitting arrays of pointers. The pointers themselves would need to be deep copied as well.