Re: [PATCH 00/15] Rearrange xcalloc arguments
On Mon, May 26, 2014 at 04:37:41PM -0700, Jeremiah Mahler wrote: xcalloc takes two arguments: the number of elements and their size. The vast majority of the Git codebase passes these arguments in the correct order, but there are some exceptions. This patch series corrects those exceptions. Let me see if I understand the issue underlying this patch set. xcalloc works like calloc and takes two arguments, the number of elements and the size of each element. However, many calls specified these arguments in the reverse order. It didn't produce a compile error because both arguments are the same type. And it didn't produce a run time error because A*B is the same as B*A. Yes, I think that is a good summary. It may be theoretically possible that an implementation of calloc() can use the distinction between the two arguments to adjust the padding or alignment of the result. However, I don't know if any implementation actually does this, or if it is even true in theory. You can find some discussions[1,2] online, but nothing conclusive. The most plausible theory I saw is that early KR C may have done something clever here, but ANSI C alignment requirements effectively remove any wiggle room for the implementation. But it certainly does not hurt to follow the spec and be consistent. -Peff [1] http://stackoverflow.com/questions/501839/is-calloc4-6-the-same-as-calloc6-4 [2] https://groups.google.com/d/msg/comp.lang.c/jZbiyuYqjB4/NIAmeNd11IoJ -- 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
[PATCH 00/15] Rearrange xcalloc arguments
xcalloc takes two arguments: the number of elements and their size. The vast majority of the Git codebase passes these arguments in the correct order, but there are some exceptions. This patch series corrects those exceptions. Brian Gesiak (15): builtin/add.c: rearrange xcalloc arguments builtin/ls-remote.c: rearrange xcalloc arguments builtin/remote.c: rearrange xcalloc arguments commit.c: rearrange xcalloc arguments config.c: rearrange xcalloc arguments diff.c: rearrange xcalloc arguments hash.c: rearrange xcalloc arguments hash.h: rearrange xcalloc arguments http-push.c: rearrange xcalloc arguments imap-send.c: rearrange xcalloc arguments notes.c: rearrange xcalloc arguments pack-revindex.c: rearrange xcalloc arguments reflog-walk.c: rearrange xcalloc arguments remote.c: rearrange xcalloc arguments transport-helper.c: rearrange xcalloc arguments builtin/add.c | 2 +- builtin/ls-remote.c | 2 +- builtin/remote.c| 8 commit.c| 2 +- config.c| 4 ++-- diff.c | 2 +- hash.c | 2 +- hash.h | 2 +- http-push.c | 2 +- imap-send.c | 2 +- notes.c | 6 +++--- pack-revindex.c | 2 +- reflog-walk.c | 8 remote.c| 2 +- transport-helper.c | 2 +- 15 files changed, 24 insertions(+), 24 deletions(-) -- 2.0.0.rc1.543.gc8042da -- 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: [PATCH 00/15] Rearrange xcalloc arguments
Brian, On Tue, May 27, 2014 at 12:33:41AM +0900, Brian Gesiak wrote: xcalloc takes two arguments: the number of elements and their size. The vast majority of the Git codebase passes these arguments in the correct order, but there are some exceptions. This patch series corrects those exceptions. Let me see if I understand the issue underlying this patch set. xcalloc works like calloc and takes two arguments, the number of elements and the size of each element. However, many calls specified these arguments in the reverse order. It didn't produce a compile error because both arguments are the same type. And it didn't produce a run time error because A*B is the same as B*A. If this behaved like dd, performance would be different depending on the order. dd if=in of=out bs=1count=1024 dd if=in of=out bs=1024 count=1 Nonetheless, it appears to be a good fix. Nice job! -- Jeremiah Mahler jmmah...@gmail.com http://github.com/jmahler -- 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