Hi Martin,

So that worked for getting the proper value, but the method I was using to get the second argument (argv+1) no longer works. Presumably because the "next" location is no longer the same.

So should I chuck this idea of using a single struct that mirrors the A_GIMME arguments and multiple structs specific to each function?

One reason for making the threadargs struct was the possibility of using a single function to wrap and execute all threads, just passing the args over for the thread function to make sense of them (though I could not figure out how to use a single wrapper).

Or is there a way to get at the second argument in threadargs->argv I'm not seeing?

I've not committed the changed code using malloc, but you can get the gist from the code currently in:

svn:pure-data/trunk/externals/bbogart/gphoto

Thanks Martin,
B. Bogart

PS: I'll be exhibiting DM in Montreal for Elektra this summer!

Martin Peach wrote:
Maybe easiest and safest is to make sure sizeof(gphoto_gimme_struct) is big enough to hold some maximum number of args by declaring it a fixed size:

#define MAXARGS 339966
    t_atom argv[MAXARGS];

instead of

    t_atom *argv;

and then copy up to MAXARGS atoms in a loop:

    for (i = 0; (i < argc)&&(i < MAXARGS); ++i)
      threadargs->argv[i] = argv[i];

instead of

    threadArgs->argv = argv;

...or you could leave the struct alone and separately allocate the precise amount of memory for argc atoms, as

    threadArgs->argv = malloc(sizeof(*argv)*argc));

and then copy them over.

Martin


B. Bogart wrote:
Thanks Martin,

I can't get the syntax right, care to give me a hint?

B. Bogart

[email protected] wrote:
So what have I misunderstood?

argv is a pointer, it's size is 4. You're still not copying whatever argv is pointing to.

Martin

_______________________________________________
Pd-dev mailing list
[email protected]
http://lists.puredata.info/listinfo/pd-dev


_______________________________________________
Pd-dev mailing list
[email protected]
http://lists.puredata.info/listinfo/pd-dev





_______________________________________________
Pd-dev mailing list
[email protected]
http://lists.puredata.info/listinfo/pd-dev

Reply via email to