All of lore.kernel.org
 help / color / mirror / Atom feed
* Conventions on struct copying?
@ 2014-06-18 23:31 brian m. carlson
  2014-06-19 17:10 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: brian m. carlson @ 2014-06-18 23:31 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 907 bytes --]

I'm still working on the struct object_id patches, and I had a style
question.  In several places throughout the code, we do something like
this:

  unsigned char a[20], b[20];

  /* do some stuff with b */
  hashcpy(a, b);

I could implement an oidcpy that does the same thing.

  struct object_id a, b;

  /* do some stuff with b */
  oidcpy(&a, &b);

Or I could just write that as:

  a = b;

and let the compiler do the heavy lifting.  Is there any reason that
we'd want the function for that purpose, or is it okay to just use the
assignment?  I don't know of any place we explicitly copy structs like
this, but I don't know of any prohibition against it, either.

-- 
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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-20  1:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-18 23:31 Conventions on struct copying? brian m. carlson
2014-06-19 17:10 ` Junio C Hamano
2014-06-19 17:22   ` Jason Pyeron
2014-06-20  1:26     ` brian m. carlson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.