From: Jonathan Nieder <jrnieder@gmail.com>
To: Yann Dirson <ydirson@altern.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/4] Introduce "abstract class" to make _locate_element() more independant of diff_rename_dst.
Date: Thu, 4 Nov 2010 15:56:55 -0500 [thread overview]
Message-ID: <20101104205655.GB18187@burratino> (raw)
In-Reply-To: <1288902795-8597-4-git-send-email-ydirson@altern.org>
Yann Dirson wrote:
> --- a/diffcore-rename.c
> +++ b/diffcore-rename.c
> @@ -6,12 +6,16 @@
> #include "diffcore.h"
> #include "hash.h"
>
> +
> +/* "Abstract class" for lists of filespecs */
> +struct dst_obj {
> + struct diff_filespec *two;
> +};
> #define locate_element(list,elem,insert_ok) \
> _locate_element(elem, &list##_nr, &list##_alloc, \
> sizeof(*list), insert_ok)
>
> -/* Table of rename/copy destinations */
> -
> +/* Table of rename/copy destinations, "subclass" of dst_obj */
> static struct diff_rename_dst {
> struct diff_filespec *two;
Nit: language lawyers might be happier with:
struct dst_obj {
struct diff_filespec *spec
};
struct diff_rename_dst {
struct dst_obj two;
...
};
or
typedef struct diff_filespec *dst_obj;
struct diff_rename_dst {
dst_obj two;
...
};
or
struct diff_rename_dst {
struct diff_filespec *two;
...
};
...
struct diff_filespec **dst = (const char *) rename_dst + next * elem_size;
to avoid violating strict aliasing rules.
Meanwhile, something like
#define container_of(ptr, type, member) \
((type *)((char *) ptr - offsetof(type, member)))
can be useful for making the meaning more obvious when downcasting.
next prev parent reply other threads:[~2010-11-04 20:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-04 20:33 [RFC PATCH] generalizing sorted-array handling Yann Dirson
2010-11-04 20:33 ` [PATCH 1/4] Start to replace locate_rename_dst() with a generic function Yann Dirson
2010-11-04 20:45 ` Jonathan Nieder
2010-11-04 21:22 ` Yann Dirson
2010-11-04 20:33 ` [PATCH 2/4] Abstract _locate_element() some more with elem_size parameter Yann Dirson
2010-11-04 20:33 ` [PATCH 3/4] Introduce "abstract class" to make _locate_element() more independant of diff_rename_dst Yann Dirson
2010-11-04 20:56 ` Jonathan Nieder [this message]
2010-11-04 20:33 ` [PATCH 4/4] Remove remaining rename_dst references in _locate_element() and pass a pointer to it Yann Dirson
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=20101104205655.GB18187@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=ydirson@altern.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;
as well as URLs for NNTP newsgroup(s).