[Tarantool-patches] [PATCH v2 02/15] module api: expose box region
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun Oct 11 18:26:59 MSK 2020
Thanks for the patch!
See 3 comments below.
> diff --git a/src/lib/core/fiber.h b/src/lib/core/fiber.h
> index 16ee9f414..11ca278e5 100644
> --- a/src/lib/core/fiber.h
> +++ b/src/lib/core/fiber.h
> @@ -386,6 +386,82 @@ struct slab_cache;
> +/**
> + * Allocate size bytes from the box region.
> + *
> + * Don't use this function to allocate a memory block for a value
> + * or array of values of a type with alignment requirements. A
> + * violation of alignment requrements leads to undefined
1. requrements -> requirements.
> + * behaviour.
> + */
> +API_EXPORT void *
> +box_region_alloc(size_t size);
> +
> +/**
> + * Allocate size bytes from the box region with given alignment.
> + *
> + * Alignment must be a power of 2.
> + */
> +API_EXPORT void *
> +box_region_aligned_alloc(size_t size, size_t alignment);
2. Do you think we should add a protection against stupidness?
For example, validate that the alignment is actually a power of 2,
at runtime, in release build too? Or leave it on user's
conscience?
> +
> +/**
> + * Truncate the box region to the given size.
> + */
> +void
> +box_region_truncate(size_t size);
> +
> /** \endcond public */
>
> /**
> diff --git a/test/app-tap/module_api.c b/test/app-tap/module_api.c
> index a79fbed0d..b5949cde4 100644
> --- a/test/app-tap/module_api.c
> +++ b/test/app-tap/module_api.c
> @@ -15,6 +15,10 @@
> #define STR2(x) #x
> #define STR(x) STR2(x)
>
> +#ifndef lengthof
> +#define lengthof(array) (sizeof (array) / sizeof ((array)[0]))
> +#endif
3. Extra whitespace after 'sizeof'.
More information about the Tarantool-patches
mailing list