Description

The init() function is used to create a variable of Queue type. It allocates memory for its container and sets main parameters of the queue.

Warning
This function should be always called when you stop using the queue, otherwise you can get memory leaks.

Function signature

Queue init(int size);

Parameters

The function takes one parameter - the size of the queue. The size of the queue is the number of elements that can be stored in the queue. It should be greater than 0, otherwise the function returns QUEUE_NULL - the null valued Queue variable, which won’t work.

Return value

The function returns a pointer to the created queue. If the queue was created successfully, the function returns a pointer to the created queue. If the queue wasn’t created properly, the function returns QUEUE_NULL - the null valued Queue variable, which won’t work.