# Utils¶

## Check¶

void check_renderer(SDL_Renderer *pRenderer)
Parameters: pRenderer (SDL_Renderer) – The SDL2 Renderer void void

Check the validity of the SDL_Renderer.

if (pRenderer == NULL) {
fprintf(stderr,"SDL Renderer error (%s)\n",SDL_GetError());
exit(EXIT_FAILURE) ;
}


Note

Function used in all displaying functions.

void check_form(Form *form)
Parameters: form (Form) – the form to check. void void

Check only if the given parameter is equal to NULL.

if (form == NULL) {
fprintf(stderr,"Invalid form argument !\n");
exit(EXIT_FAILURE) ;
}


Note

Function used in all forms setters functions and all forms operations functions.

## Memory¶

Form *new_form(uint32_t count)
Parameters: pRenderer (uint32_t) – the number of coordinates pair to allocate. Form A new allocated Form

This function allocate the required space for the given count argument number of coordinates arrays.

And set the count member from the returned Form.

Warning: The other members must you set yourself.
void free_form(Form *form)
Parameters: form (Form) – the form to free. void void

This function free the allocated coordinates arrays from the Form, free the form pointer and set it on NULL.