Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Should al_get_system_config result be destroyed with al_destroy_config?

This thread is locked; no one can reply to it. rss feed Print
Should al_get_system_config result be destroyed with al_destroy_config?
axilmar
Member #1,204
April 2001

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

Audric
Member #907
January 2001

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
Member #23
April 2000

No.

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

Thomas Fjellstrom
Member #476
June 2000
avatar

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.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

kazzmir
Member #1,786
December 2001
avatar

I just made a note of this in bf960470dc.

Audric
Member #907
January 2001

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

Thomas Fjellstrom
Member #476
June 2000
avatar

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.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Go to: