floodfill question
Richard Phipps

In flood.c of the allegro source I see it grows an area of scratch memory. Which is defined in the aintern.h file:

AL_INLINE(void, _grow_scratch_mem, (int size),
{
   if (size > _scratch_mem_size) {
      size = (size+1023) & 0xFFFFFC00;
      _scratch_mem = realloc(_scratch_mem, size);
      _scratch_mem_size = size;
   }
})

But I can't see where this memory is freed, does this memory always sit in the background after a floodfill? Am I missing something..???

Bob

scratch memory is used throughout Allegro and is shared everywhere. It's only freed when Allegro exits.

ReyBrujo

Yeah, I was at a miss the first time I checked polygon source. I wonder if you declare it extern and link with Allegro, later you can use it for your own purposes...

1/* allegro_exit:
2 * Closes down the Allegro system.
3 */
4void allegro_exit()
5{
6 while (exit_func_list)
7 (*(exit_func_list->funcptr))();
8 
9 if (system_driver) {
10 system_driver->exit();
11 system_driver = NULL;
12 }
13 
14 if (_scratch_mem) {
15 free(_scratch_mem);
16 _scratch_mem = NULL;
17 _scratch_mem_size = 0;
18 }
19}

Richard Phipps

Repeated use of floodfill seems to be growing this scratch_memory too much. Is there a way I can free the memory after each fill, without damaging the rest of Allegro?

Bob
Quote:

Repeated use of floodfill seems to be growing this scratch_memory too much. Is there a way I can free the memory after each fill, without damaging the rest of Allegro?

The scratch memory is reused between floodfills. You'll only end up allocating enough scratch to do the largest floodfill you've ever done.

Richard Phipps

Ah I see, I misunderstood. Sorry about that! :)

Thread #417376. Printed from Allegro.cc