Should al_get_system_config result be destroyed with al_destroy_config?
axilmar

The manual doesn't say if the ALLEGRO_CONFIG returned by al_get_system_config should be destroyed or not.

Audric

Yes. al_get_system_config() returns a newly allocated piece of data, it's up to you to release it when you don't need it anymore.

Peter Wang

No.

ALLEGRO_CONFIG *al_get_system_config(void)
{
   return (active_sysdrv) ? active_sysdrv->config : NULL;
}

Thomas Fjellstrom
Audric said:

Yes. al_get_system_config() returns a newly allocated piece of data, it's up to you to release it when you don't need it anymore.

Gets tend not to work that way. Typically "create" or "new" type functions you pair up with "destroy" or "delete" functions, where as with a "get" you just leave it be. Not everyone follows that pattern, but its pretty common.

kazzmir

I just made a note of this in bf960470dc.

Audric

Woops sorry. Seeing how the returned pointer was not const, I didn't think this would give direct access.

Thomas Fjellstrom
Audric said:

Seeing how the returned pointer was not const, I didn't think this would give direct access.

It's a pointer. You can always directly access the memory it points at.

Thread #612361. Printed from Allegro.cc