Re: Conventions on struct copying?
brian m. carlson sand...@crustytoothpaste.net writes: I don't know of any place we explicitly copy structs like this,... which should be a reason enough. The first concrete guideline is just imitate the existing code. but I don't know of any prohibition against it, either. So now you know ;-). -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: Conventions on struct copying?
-Original Message- From: Junio C Hamano Sent: Thursday, June 19, 2014 13:11 brian m. carlson sand...@crustytoothpaste.net writes: I don't know of any place we explicitly copy structs like this,... which should be a reason enough. The first concrete guideline is just imitate the existing code. but I don't know of any prohibition against it, either. So now you know ;-). To expand, on that do not trust the compiler to do deep copies. http://stackoverflow.com/questions/2302351/assign-one-struct-to-another-in-c Hit #1 on https://www.google.com/search?q=c+assignment+of+struct -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - - Jason Pyeron PD Inc. http://www.pdinc.us - - Principal Consultant 10 West 24th Street #100- - +1 (443) 269-1555 x333Baltimore, Maryland 21218 - - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- This message is copyright PD Inc, subject to license 20080407P00. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Conventions on struct copying?
On Thu, Jun 19, 2014 at 01:22:44PM -0400, Jason Pyeron wrote: -Original Message- From: Junio C Hamano Sent: Thursday, June 19, 2014 13:11 brian m. carlson sand...@crustytoothpaste.net writes: I don't know of any place we explicitly copy structs like this,... which should be a reason enough. The first concrete guideline is just imitate the existing code. Right. The reason I asked is that most of our structures end up containing pointers, so it wouldn't make sense to do the equivalent of a memcpy on them anyways. This is just data, so I thought it might be different. I'll implement an oidcpy function to do the work. but I don't know of any prohibition against it, either. So now you know ;-). To expand, on that do not trust the compiler to do deep copies. I'm not. The definition looks like; struct object_id { unsigned char sha1[20]; }; I only want it to memcpy those 20 bytes; there's no pointers or anything to complicate it. -- brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187 signature.asc Description: Digital signature