Hi,
Maybe this question is a bit dumb but in this example the timer works after al_destroy_timer() completely correct. I thougt it should return an error or something else but it is no problem to use a timer after it is destroyed.
Is this a bug or am i an idiot?
thanks for all answers
It's a bug in your code, yes. See the Allegro source:
/* Function: al_destroy_timer */ void al_destroy_timer(ALLEGRO_TIMER *timer) { if (timer) { al_stop_timer(timer); _al_unregister_destructor(_al_dtor_list, timer); _al_event_source_free(&timer->es); al_free(timer); } }
You are just using memory that you no longer own. It may "work," but it could explode at any moment.
You'll have problems later when something else starts using the memory that timer previously used. You should never use objects after they have been freed.
ahh, ok
thank you very much for the answers