<br><br><div class="gmail_quote">On Sat, Apr 24, 2010 at 7:45 AM, Jarek Jasiewicz <span dir="ltr"><<a href="mailto:jarekj@amu.edu.pl">jarekj@amu.edu.pl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Maris Nartiss pisze:<div class="im"><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br>
this module was running just fine on my ~AMD64 Gentoo, still Valgrind<br>
was complaining a bit (no idea if it's harmfull in Your code):<br>
Calculate...<br>
0% ==28214== Invalid read of size 4<br>
==28214== at 0x402388: fuzzy (fuzzylogic.c:8)<br>
==28214== by 0x405055: implicate (system.c:41)<br>
==28214== by 0x4034C4: main (main.c:186)<br>
==28214== Address 0x5e8e360 is not stack'd, malloc'd or (recently) free'd<br>
==28214==<br>
==28214== Invalid read of size 4<br>
==28214== at 0x402393: fuzzy (fuzzylogic.c:10)<br>
==28214== by 0x405055: implicate (system.c:41)<br>
==28214== by 0x4034C4: main (main.c:186)<br>
==28214== Address 0x5e8e364 is not stack'd, malloc'd or (recently) free'd<br>
==28214==<br>
16% 33% 50% 66% 83% 100% Close...<br>
<br>
<br>
Maris.<br>
<br>
</blockquote></div>
Thanks Maris,<br>
this is that which cause segment fault 32 bit, thanks very much<br>
The problem Is I do not know how to fix it....<br></blockquote><div><br>I have some suggestions but don't know if these would fix it.<br><br>I could not find where you allocate memory for s_maps[output_index].sets, only for sets in input maps. Maybe it's worth to add some more debug statements and checks? Init sets to NULL, then if(s_maps[output_index].sets) G_fatal_error("Oops forgot sets"); then you would know what to fix.<br>
<br>Fixing compiler warnings (the line numbers refer to the formatted version in svn):<br>fuzzylogic.c:86:<br> return (x == y == 0) ? 0 : (x * y) / ((x + y) - x * y);<br>rather<br> return (x == 0 || y == 0) ? 0 : (x * y) / ((x + y) - x * y);<br>
<br>x == y == 0 is nonsense anyway<br><br>helpers.c:35<br> for (a = b = buf; *a == rem || *a == ' ' || *a == ' \t'; a++) ;<br>must be<br> for (a = b = buf; *a == rem || *a == ' ' || *a == '\t'; a++) ;<br>
<br>io.c: function ‘create_output_maps’:<br><br>add<br> return 1;<br>or make it<br>void create_output_maps(void)<br><br>local_proto.h:175<br>add<br>int get_cells(int col);<br><br>system.c:67<br> /* -- -- -- -- -- -- -- --<br>
must be<br> /* -- -- -- -- -- -- -- -- */<br><br><br>system.c:142<br>add<br> default:<br> break;<br><br>system.c function<br>float parse_expression(int n)<br>has no return value<br>
<br>system.c:41<br> consequent = fuzzy(universe[i],<br> &s_maps[output_index].sets[set_index]);<br> set_index = s_rules[j].output_set_index;<br>should rather be<br> set_index = s_rules[j].output_set_index;<br>
consequent = fuzzy(universe[i],<br> &s_maps[output_index].sets[set_index]);<br><br>or put<br> set_index = s_rules[j].output_set_index;<br>just before <br> for (i = 0; i < resolution; ++i) {<br>
<br>The code would be somewhat easier to read if variables would not have the same name like custom typedefs, e.g. typedef struct map and char map[30].<br><br>HTH,<br><br>Markus<br><br></div><br></div>