Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » floodfill question

This thread is locked; no one can reply to it. rss feed Print
floodfill question
Richard Phipps
Member #1,632
November 2001
avatar

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
Free Market Evangelist
September 2000
avatar

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

--
- Bob
[ -- All my signature links are 404 -- ]

ReyBrujo
Moderator
January 2001
avatar

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}

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Richard Phipps
Member #1,632
November 2001
avatar

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
Free Market Evangelist
September 2000
avatar

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.

--
- Bob
[ -- All my signature links are 404 -- ]

Richard Phipps
Member #1,632
November 2001
avatar

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

Go to: