git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Abhishek Kumar <abhishekkumar8222@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] oidmap: make oidmap_free independent of struct layout
Date: Wed, 8 Apr 2020 17:54:23 -0400	[thread overview]
Message-ID: <20200408215423.GA3468797@coredump.intra.peff.net> (raw)
In-Reply-To: <20200408040659.14511-1-abhishekkumar8222@gmail.com>

On Wed, Apr 08, 2020 at 09:36:58AM +0530, Abhishek Kumar wrote:

> c8e424c introduced hashmap_free_entries, which can free any struct
> pointer, regardless of the hashmap_entry field offset.
> 
> oidmap does not make use of this flexibilty, hardcoding the offset to
> zero instead. Let's fix this by passing struct type and member to
> hashmap_free_entries.

I'm not sure how much this improves anything.

We're now telling the hashmap code how to get to our "struct
oidmap_entry" pointer by using the correct offset there. But we know
that offset will always be 0, because we put our internal hashmap entry
at the start of oidmap_entry.

What you can't do is:

  struct foo {
    int first_member;
    struct oidmap_entry not_the_first_member;
  };

and work directly with "struct foo" pointers. You have to convert
oidmap_entry pointers into foo pointers with container_of() or similar.
And that is true both before and after your patch.

That said, I don't mind doing this as a cleanup; there's a subtle
dependency on the location of internal_entry within object_entry,
and this would move towards getting rid of it.

-Peff

  parent reply	other threads:[~2020-04-08 21:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08  4:06 [PATCH 1/2] oidmap: make oidmap_free independent of struct layout Abhishek Kumar
2020-04-08  4:06 ` [PATCH 2/2] oidmap: rework iterators to return typed pointer Abhishek Kumar
2020-04-08  6:02 ` [PATCH 1/2] oidmap: make oidmap_free independent of struct layout Junio C Hamano
2020-04-08  7:03 ` [PATCH v2 " Abhishek Kumar
2020-04-08  7:03   ` [PATCH v2 2/2] oidmap: rework iterators to return typed pointer Abhishek Kumar
2020-04-08 22:08     ` Jeff King
2020-04-08 21:54 ` Jeff King [this message]
2020-04-25  2:59 ` [PATCH v3 1/3] oidmap: make oidmap_free independent of struct layout Abhishek Kumar
2020-04-25  2:59   ` [PATCH v3 2/3] oidmap: rework iterators to return typed pointer Abhishek Kumar
2020-04-25  2:59   ` [PATCH v3 3/3] oidmap: return oidmap_entry pointers Abhishek Kumar

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200408215423.GA3468797@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=abhishekkumar8222@gmail.com \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).