From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: git@vger.kernel.org
Subject: Conventions on struct copying?
Date: Wed, 18 Jun 2014 23:31:29 +0000 [thread overview]
Message-ID: <20140618233129.GK368384@vauxhall.crustytoothpaste.net> (raw)
[-- 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 --]
next reply other threads:[~2014-06-18 23:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 23:31 brian m. carlson [this message]
2014-06-19 17:10 ` Conventions on struct copying? Junio C Hamano
2014-06-19 17:22 ` Jason Pyeron
2014-06-20 1:26 ` brian m. carlson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140618233129.GK368384@vauxhall.crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox