mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-10-07 18:33:09 +02:00
Corrected the cell search algorithm so that it allocates memory
for BPEnum instead of putting it in the local frame. The structure is half a megabyte and will severely limit the hierarchy depth because it is used in the recursive cell search.
This commit is contained in:
@@ -76,19 +76,23 @@ struct seeTypesArg
|
||||
* Returns 1 if the func() returns 1; otherwise returns 0 to keep the
|
||||
* search alive.
|
||||
*
|
||||
* NOTE: struct BPEnum has an array size 10000, causing this routine to
|
||||
* take up a half megabyte of stack space if the variable is declared
|
||||
* inside the local frame. Use mallocMagic() instead.
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
DBSrCellPlaneArea(BPlane *plane, Rect *rect, int (*func)(), ClientData arg)
|
||||
{
|
||||
BPEnum bpe;
|
||||
BPEnum *bpe;
|
||||
CellUse *use;
|
||||
int rval = 0;
|
||||
|
||||
BPEnumInit(&bpe, plane, rect, BPE_OVERLAP, "DBSrCellPlaneArea");
|
||||
bpe = (BPEnum *)mallocMagic(sizeof(BPEnum));
|
||||
BPEnumInit(bpe, plane, rect, BPE_OVERLAP, "DBSrCellPlaneArea");
|
||||
|
||||
while (use = BPEnumNext(&bpe))
|
||||
while (use = BPEnumNext(bpe))
|
||||
{
|
||||
if ((*func)(use, arg))
|
||||
{
|
||||
@@ -97,7 +101,8 @@ DBSrCellPlaneArea(BPlane *plane, Rect *rect, int (*func)(), ClientData arg)
|
||||
}
|
||||
}
|
||||
|
||||
BPEnumTerm(&bpe);
|
||||
BPEnumTerm(bpe);
|
||||
freeMagic(bpe);
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user