> Pd crashes every time a bang hits the object, which is what triggers the internal calculations, including reading the text files.
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.
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.
Generally, I think he doesn't understand pointers and memory management very well. Take this example:
double* coef1 = malloc(sizeof(double));
double* coef2 = malloc(sizeof(double));
double* coef3 = malloc(sizeof(double));
struct term termi;
termi.numTerm = getTermNum(line);
readTermCoefs(line, coef1, coef2, coef3);
termi.a = *coef1;
termi.b = *coef2;
termi.c = *coef3;
This should simply read:
struct term termi;
termi.numTerm = getTermNum(line);
readTermCoefs(line, &termi.a, &termi.b, &termi.c);
Note in his original code, coef1, coef2, coef3 are never freed. In fact, his code is full of those tiny memory leaks.
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.
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.
Best,
Christof
Hi all,
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
jgartens@tulane.edu
Dear Pd Community -
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.
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.
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.
My questions:
Is there some method to internally read data from text files in pd?
Are the internal calculations too much and causing pd to crash?
Are there more efficient methods of reaching my desired functionality that may help pd run more smoothly?
Thanks in advance for the help,
Jake Gartenstein
Materials:
_______________________________________________
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management ->
https://lists.puredata.info/listinfo/pd-list