All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Antill <jantill@redhat.com>
To: Karl MacMillan <kmacmillan@mentalrootkit.com>
Cc: selinux@tycho.nsa.gov
Subject: Re: [PATCH - policyrep] add objpool to libsepol
Date: Thu, 19 Apr 2007 12:58:01 -0400	[thread overview]
Message-ID: <1177001881.19144.103.camel@code.and.org> (raw)
In-Reply-To: <1176999086.13683.46.camel@localhost.localdomain>

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

On Thu, 2007-04-19 at 12:11 -0400, Karl MacMillan wrote:
> On Thu, 2007-04-19 at 11:57 -0400, James Antill wrote:

> >  I guess I just wonder why have the s->obj_free member at all, esp.
> > given the examples used with strdup() ... I kind of assumed you expected
> > input from strdup(), given the examples, and so was confused about the
> > non-useage of free().
> 
> Ahh - but the objects can be arbitrary, so they might be structs that
> need something more than free.
> 
> >  It also just seems wrong to have the member free function used for
> > input ... but if you have a use case feel free to ignore me :).
> 
> Well, the model I was thinking was that the caller was giving ownership
> of the object to the pool. The advantage is that the caller simply calls
> add and doesn't have to check return codes to see if their copy of the
> object should be freed.

 Well it needs to check for errors, and do something different then.

>  Otherwise the caller would conditionally free
> the object depending on whether another copy already existed. Object
> deletion would have the same problem.

 Yeh, I understand ... it feels kind of wrong to be mixing layers. Ie.
conceptually you seem to have:

struct higher_layer {
  void *(*make)(void); /* allocate */
  struct lower_layer {
    void (*free)(void *); /* deallocate */
  } lower;
};

...which I don't see often, and so assumed was wrong ... but it works,
you obviously meant to do it, and I can't see a quick way to split the
layers without downsides.

-- 
James Antill <jantill@redhat.com>

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

      reply	other threads:[~2007-04-19 16:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-19  1:57 [PATCH - policyrep] add objpool to libsepol Karl MacMillan
2007-04-19  4:47 ` James Antill
2007-04-19 15:35   ` Karl MacMillan
2007-04-19 15:57     ` James Antill
2007-04-19 16:11       ` Karl MacMillan
2007-04-19 16:58         ` James Antill [this message]

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=1177001881.19144.103.camel@code.and.org \
    --to=jantill@redhat.com \
    --cc=kmacmillan@mentalrootkit.com \
    --cc=selinux@tycho.nsa.gov \
    /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 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.