Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Timur Safin" <tsafin@tarantool.org>
To: 'Vladislav Shpilevoy' <v.shpilevoy@tarantool.org>,
	tarantool-patches@dev.tarantool.org, alyapunov@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH small 1/1] region: new region_alloc_array, updated alloc_object
Date: Fri, 5 Jun 2020 15:12:24 +0300	[thread overview]
Message-ID: <02dd01d63b32$92909200$b7b1b600$@tarantool.org> (raw)
In-Reply-To: <599b3e8d-cacd-b480-0a19-158fbac417f4@tarantool.org>

LGTM

: -----Original Message-----
: From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
: Sent: Thursday, June 4, 2020 12:27 AM
: To: tarantool-patches@dev.tarantool.org; alyapunov@tarantool.org;
: tsafin@tarantool.org
: Subject: Re: [Tarantool-patches] [PATCH small 1/1] region: new
: region_alloc_array, updated alloc_object
: 
: Still need 2 reviews here.
: 
: On 21/05/2020 22:32, Vladislav Shpilevoy wrote:
: > Region's API provided a macro for aligned allocation of an object:
: > region_alloc_object(). But not less frequent there is a case when
: > need to allocate an array of objects, also aligned. The patch adds
: > region_alloc_array() for that.
: >
: > Also the patch adds an out parameter 'size' for both macros. It
: > simplifies total size calculation, which is needed almost always,
: > because total size is included into an error message, if the
: > allocation fails.
: >
: > Needed for https://github.com/tarantool/tarantool/issues/4609
: > ---
: > Branch:
: http://github.com/tarantool/small/tree/gerold103/region_alloc_array
: > Issue: https://github.com/tarantool/tarantool/issues/4609
: >
: >  small/region.h | 15 ++++++++++-----
: >  1 file changed, 10 insertions(+), 5 deletions(-)
: >
: > diff --git a/small/region.h b/small/region.h
: > index bea88c6..df6567d 100644
: > --- a/small/region.h
: > +++ b/small/region.h
: > @@ -386,10 +386,15 @@ struct RegionGuard {
: >  };
: >  #endif /* __cplusplus */
: >
: > -#define region_reserve_object(region, T) \
: > -	(T *)region_aligned_reserve((region), sizeof(T), alignof(T))
: > -
: > -#define region_alloc_object(region, T) \
: > -	(T *)region_aligned_alloc((region), sizeof(T), alignof(T))
: > +#define region_alloc_object(region, T, size) ({
: 	\
: > +	*(size) = sizeof(T);							\
: > +	(T *)region_aligned_alloc((region), sizeof(T), alignof(T));
: 	\
: > +})
: > +
: > +#define region_alloc_array(region, T, count, size) ({
: 	\
: > +	int _tmp_ = sizeof(T) * (count);					\
: > +	*(size) = _tmp_;							\
: > +	(T *)region_aligned_alloc((region), _tmp_, alignof(T));
: 	\
: > +})
: >
: >  #endif /* INCLUDES_TARANTOOL_SMALL_REGION_H */
: >

      reply	other threads:[~2020-06-05 12:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21 20:32 Vladislav Shpilevoy
2020-05-25  6:52 ` Aleksandr Lyapunov
2020-05-27  0:00   ` Vladislav Shpilevoy
2020-06-05 12:11     ` Timur Safin
2020-06-03 21:27 ` Vladislav Shpilevoy
2020-06-05 12:12   ` Timur Safin [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='02dd01d63b32$92909200$b7b1b600$@tarantool.org' \
    --to=tsafin@tarantool.org \
    --cc=alyapunov@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH small 1/1] region: new region_alloc_array, updated alloc_object' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox