Thanks Claude,
I'm not done much (almost none) mem management in C.
As far as I understand it my struct is being allocated a new space in
memory with:
gphoto_gimme_struct *threadArgs = (gphoto_gimme_struct
*)malloc(sizeof(gphoto_gimme_struct));
So rather than copying the references to gphoto, s, argc and argv I
should copy the data at those locations into the newly allocated struct.
I tried as follows:
memcpy(&threadArgs->gphoto, &gphoto, sizeof(gphoto));
memcpy(&threadArgs->s, &s, sizeof(s));
memcpy(&threadArgs->argc, &argc, sizeof(argc));
memcpy(&threadArgs->argv, &argv, sizeof(argv));
I think I got the syntax right, as I can access the values.
Problem is the same issue persists. The argument still ends up being
"float" when read in the thread.
So what have I misunderstood?
Thanks for your help,
B. Bogart
Claude Heiland-Allen wrote:
Hi,
B. Bogart wrote:
The problem is passing the A_GIMME arguments from a wrapper function
to a function that runs in a separate thread.
[snip]
This is the thread safety problem right here:
threadArgs->argv = argv;
You need to *copy* *all* the data needed by the child thread that might
be modified in the main thread later.
[snip]
In PD <.0.40.3 the proper argument is printed from both the thread and
in the spawning function.
You've just been lucky!
How does the symbol "input.jpg" end up turning into "float" in 0.42.4?
It could turn into anything - when the inlet method exits pd can do what
it likes with the argv memory...
Any ideas for solutions?
Copy the argv array into new memory.
Claude
_______________________________________________
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev
_______________________________________________
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev