<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div>Hi Rick,</div>

<div> </div>

<div>> Pd crashes every time a bang hits the object, which is what triggers the internal calculations, including reading the text files.</div>

<div> </div>

<div>Actually, it should also crash when using the float inlets. The problem is that his object contains a "struct date *mydate;" member which points to nowhere. Accessing this pointer will of course lead to a segfault. It should be a "struct date mydate;" instead.</div>

<div> </div>

<div>Also, all the "t_atom mer[3]", "t_atom ven[3]", etc. members are only used in trackingPlanets_bang, so they should be local variables.</div>

<div> </div>

<div>
<div>Generally, I think he doesn't understand pointers and memory management very well. Take this example:</div>

<div> </div>

<div>double* coef1 = malloc(sizeof(double));<br/>
double* coef2 = malloc(sizeof(double));<br/>
double* coef3 = malloc(sizeof(double));<br/>
struct term termi;<br/>
termi.numTerm = getTermNum(line);<br/>
readTermCoefs(line, coef1, coef2, coef3);<br/>
termi.a = *coef1;<br/>
termi.b = *coef2;<br/>
termi.c = *coef3;</div>

<div> </div>

<div>This should simply read:</div>

<div> </div>

<div>struct term termi;<br/>
termi.numTerm = getTermNum(line);<br/>
readTermCoefs(line, &termi.a, &termi.b, &termi.c);</div>

<div> </div>

<div>Note in his original code, coef1, coef2, coef3 are never freed. In fact, his code is full of those tiny memory leaks.</div>

<div> </div>

<div>I don't want to sound too harsh but I think Jacob needs to first learn the basics of the C programming language before attempting to write a Pd external. There are some good books and tutorials with lots of practical exerices. Also, he might want to show his code to a more experienced C programmer (might be a teacher or colleague) to get some feedback.</div>

<div> </div>

<div>Also, I highly recommend learning the very basics of a debugger to find out where your program crashes. Assuming he's using GCC, it's enough to start Pd in the debugger, e.g. "gdb --args pd ./mypatch.pd" -> "run", and after the crash type "bt" to get the backtrace.</div>

<div> </div>

<div>Best,</div>

<div> </div>

<div>Christof</div>

<div> </div>

<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Donnerstag, 15. August 2019 um 22:28 Uhr<br/>
<b>Von:</b> "Rick Snow" <ricksnow@gmail.com><br/>
<b>An:</b> pd-list@lists.iem.at<br/>
<b>Cc:</b> "Gartenstein, Jacob P" <jgartens@tulane.edu><br/>
<b>Betreff:</b> [PD] Student Project Advice</div>

<div name="quoted-content">
<div>Hi all,
<div> </div>

<div>I have a student trying to sign up to the list and ask a question but he is having some trouble being approved to this list.  I am pasting his question below and will send any responses to him!  Thanks for any advice you might have.  His email address is <a href="mailto:jgartens@tulane.edu" onclick="parent.window.location.href='mailto:jgartens@tulane.edu'; return false;" target="_blank">jgartens@tulane.edu</a></div>

<div> </div>

<div>
<div id="divRplyFwdMsg" style="font-family: Calibri , Helvetica , sans-serif;font-size: 16.0px;"><font color="#000000" face="Calibri, sans-serif" style="font-size: 11.0pt;"><b>From:</b> Gartenstein, Jacob P<br/>
<b>Sent:</b> Wednesday, August 14, 2019 12:50 AM<br/>
<b>To:</b> <a href="mailto:pd-list@lists.iem.at" onclick="parent.window.location.href='mailto:pd-list@lists.iem.at'; return false;" target="_blank">pd-list@lists.iem.at</a> <<a href="mailto:pd-list@lists.iem.at" onclick="parent.window.location.href='mailto:pd-list@lists.iem.at'; return false;" target="_blank">pd-list@lists.iem.at</a>><br/>
<b>Subject:</b> Questions about External </font>

<div> </div>
</div>

<div style="font-family: Calibri , Helvetica , sans-serif;font-size: 16.0px;">
<div id="x_divtagdefaultwrapper" style="font-size: 12.0pt;">
<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;">Dear Pd Community - </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"> </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;">I'm trying to create an object, via a pd external, which takes in several parameters, does internal calculations, and outputs several lists of floats.  </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;">Part of the internal calculation process includes reading thousands of lines of equation coefficients from text documents.  These coefficients, along with the input parameters, are necessary to perform the internal calculations.  </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"> </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;">I've linked the pd external, entitled trackingPlanets, which creates in pd but doesn't perform any of the desired functionality.  Pd crashes every time a bang hits the object, which is what triggers the internal calculations, including reading the text files.  Through the course of some tests, I've discovered that the text file reading functions cause pd to crash. </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"> </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;">My questions:</div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"> </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"><span style="font-size: 12.0pt;">Is there some method to internally read data from text files in pd?</span></div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"> </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"><span style="font-size: 12.0pt;">Are the internal calculations too much and causing pd to crash?</span></div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"> </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"><span style="font-size: 12.0pt;">Are there more efficient methods of reaching my desired functionality that may help pd run more smoothly?</span></div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"> </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"><span style="font-size: 12.0pt;">Thanks in advance for the help,</span></div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"> </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"><span style="font-size: 12.0pt;">Jake Gartenstein </span></div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"> </div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;">Materials:</div>

<div style="margin-top: 0.0px;margin-bottom: 0.0px;font-family: Calibri , Helvetica , sans-serif , serif , EmojiFont;"><a class="x_x_OWAAutoLink" href="https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fdrive%2Ffolders%2F1KYB9GyP31I9tGfwFnY7ctfUH24qvClXa%3Fusp%3Dsharing&data=02%7C01%7Crsnow%40tulane.edu%7C27f33351311e468b113508d721beaad3%7C9de9818325d94b139fc34de5489c1f3b%7C0%7C0%7C637014975096336581&sdata=ktqk8oIAPoijOZ2rONBoGoJYdtKQvCqBg6BJNrAIlQo%3D&reserved=0" id="LPlnk555889" tabindex="-1" target="_blank">https://drive.google.com/drive/folders/1KYB9GyP31I9tGfwFnY7ctfUH24qvClXa?usp=sharing</a></div>
</div>
</div>

<div> </div>
</div>
_______________________________________________ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> <a href="https://lists.puredata.info/listinfo/pd-list" target="_blank">https://lists.puredata.info/listinfo/pd-list</a></div>
</div>
</div>
</div>
</div></div></body></html>