SlotFactory_init()

Initialize a slot factory instance.

Synopsis:

#include <asr/slot-factory.h>
 
bool SlotFactory_init(SlotFactory *self, unsigned int num_slots, unsigned int *page_size)

Arguments:

self

A pointer to the slot factory instance to initialize.

num_slots

The number of slot entries that the initial buffer of the factory can hold.

page_size

A pointer to a buffer containing the page size to use when allocating ASR slot entry buffers. The value obtained from this optional argument is aligned to the next 32-bit aligned value that is large enough to hold the specified page size.

Library:

libasr

Description:

The SlotFactory_init() function creates a new slot entry buffer large enough to contain num_slots entries. If self was previously initialized, the memory it manages is leaked. Therefore, this function should not be called twice on the same slot factory instance.

Returns:

True if the factory is initialized; false if an error occurs during initialization. In the error case, errno is set to indicate the error that ocurred: either EINVAL if self refers to an invalid slot factory instance or ENOMEM if the slot entry buffer cannot be allocated.