[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] Crash report for OS X Segmentation fault
From: |
Arend Bayer |
Subject: |
Re: [gnugo-devel] Crash report for OS X Segmentation fault |
Date: |
Fri, 11 Jan 2002 17:40:25 +0100 (CET) |
Gunnar wrote:
> Dan wrote:
> > > Yes, declaring it static fixes the problem. I'm not familiar with
> > > contributing code or patches to gnugo, so could please one of you guys
> > > fix it? Thanks.
> >
> > It's already changed in the CVS. See the patch:
> >
> > http://www.gnu.org/software/gnugo/patches/static_moyo_1_20.1
>
> Here's a different solution which substantially reduces the memory
> requirements for that function.
As the gnu mail server seems to have some problems (e.g. I got trevor's latest
patch with 2 days delay) I don't know whether you already got my previous
message where I mentioned a similar patch in preparation. My patch just
reduces the array size in the declaration of moyo_is_adjacent to the size
actually needed. (When I wrote the original declaration, I must have
assumed that the moyo size is stored in the draon array, not the dragon2
array.)
Compared to Gunnar's solution, this patch may need a little more memory
but should be slightly faster. I have no strong feelings about which one
might be preferrable.
-Arend
Index: engine/dragon.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/dragon.c,v
retrieving revision 1.44
diff -u -r1.44 dragon.c
--- engine/dragon.c 8 Jan 2002 22:34:14 -0000 1.44
+++ engine/dragon.c 10 Jan 2002 22:41:25 -0000
@@ -1577,32 +1577,34 @@
int i, j;
int pos;
int m, n;
- int result[MAX_BOARD * MAX_BOARD];
- static int moyo_is_adjacent[MAX_BOARD * MAX_BOARD][MAX_MOYOS + 1];
+ int result[number_of_dragons];
struct moyo_data moyos;
influence_get_moyo_segmentation(opposite, &moyos);
- for (i = 0; i < number_of_dragons; i++) {
- result[i] = 0;
- for (j = 1; j <= moyos.number; j++)
- moyo_is_adjacent[i][j] = 0;
- }
-
- for (m = 0; m < board_size; m++)
- for (n = 0; n < board_size; n++) {
- pos = POS(m, n);
- if (moyos.segmentation[pos] != 0
- && board[pos] == moyos.owner[moyos.segmentation[pos]])
- moyo_is_adjacent[dragon[pos].id][moyos.segmentation[pos]] = 1;
+ {
+ int moyo_is_adjacent[number_of_dragons][moyos.number + 1];
+ for (i = 0; i < number_of_dragons; i++) {
+ result[i] = 0;
+ for (j = 1; j <= moyos.number; j++)
+ moyo_is_adjacent[i][j] = 0;
}
- for (i = 0; i < number_of_dragons; i++) {
- for (j = 1; j <= moyos.number; j++) {
- if (moyo_is_adjacent[i][j])
- result[i] += moyos.size[j];
+ for (m = 0; m < board_size; m++)
+ for (n = 0; n < board_size; n++) {
+ pos = POS(m, n);
+ if (moyos.segmentation[pos] != 0
+ && board[pos] == moyos.owner[moyos.segmentation[pos]])
+ moyo_is_adjacent[dragon[pos].id][moyos.segmentation[pos]] = 1;
+ }
+
+ for (i = 0; i < number_of_dragons; i++) {
+ for (j = 1; j <= moyos.number; j++) {
+ if (moyo_is_adjacent[i][j])
+ result[i] += moyos.size[j];
+ }
+ if (result[i] < dragon2[i].moyo)
+ dragon2[i].moyo = result[i];
}
- if (result[i] < dragon2[i].moyo)
- dragon2[i].moyo = result[i];
}
}
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, (continued)
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Marco Scheurer, 2002/01/09
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Dave Denholm, 2002/01/09
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Daniel Bump, 2002/01/09
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Dave Denholm, 2002/01/09
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Dave Denholm, 2002/01/09
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Gunnar Farneback, 2002/01/09
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Dave Denholm, 2002/01/09
- pattern matcher (was Re: [gnugo-devel] Crash report for OS X Segmentation fault), Dave Denholm, 2002/01/10
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Daniel Bump, 2002/01/09
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Gunnar Farneback, 2002/01/10
- Re: [gnugo-devel] Crash report for OS X Segmentation fault,
Arend Bayer <=
- Re: [gnugo-devel] Crash report for OS X Segmentation fault, Gunnar Farneback, 2002/01/11