[systemd-devel] RFC : PATCH: initial implementation of system wide rlimit
Frederic Crozat
fcrozat at suse.com
Tue Apr 3 06:44:49 PDT 2012
Le lundi 02 avril 2012 à 22:59 +0200, Lennart Poettering a écrit :
> On Fri, 30.03.12 17:20, Frederic Crozat (fcrozat at suse.com) wrote:
>
> > >From 5008080dda662208278c159213adbd5211496043 Mon Sep 17 00:00:00 2001
> > From: Frederic Crozat <fcrozat at suse.com>
> > Date: Thu, 29 Mar 2012 17:53:41 +0200
> > Subject: [PATCH 1/2] macro: add newdup macro, equivalent of new + memdup but
> > type-safe
> >
> > ---
> > src/macro.h | 1 +
> > 1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/src/macro.h b/src/macro.h
> > index 19f259e..a85e72d 100644
> > --- a/src/macro.h
> > +++ b/src/macro.h
> > @@ -137,6 +137,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
> >
> > #define memzero(x,l) (memset((x), 0, (l)))
> > #define zero(x) (memzero(&(x), sizeof(x)))
> > +#define newdup(x,l) ( (x= new(typeof(*l),1)) ? memcpy((x),(l),sizeof(*l)) : NULL)
>
> Hmm, I was more thinking of a definition much closer to new() and
> new0(), without typeof, but with allowing allocation of an array
>
> #define newdup(t, p, n) ((t*)memdup(p,sizeof(t)*(n)))
New version attached, based on your comments.
--
Frederic Crozat <fcrozat at suse.com>
SUSE
More information about the systemd-devel
mailing list