On 02/21/2014 09:00 AM, Ivica Bukvic wrote:

Because this way you can reference data points with sc_vec+n as opposed to dealing with single or double linked lists (since sc_vec can be an array).


If sc_vec is a pointer then you can access data points using the same technique, which is pointer math after all.

For everyone's amusement, here's an exercise in my own rank speculation: something about a t_word array aligning on boundaries in a way that you wouldn't be able to guarantee with a pointer to a t_word.  So if you can guarantee there won't be padding you save memory in 1981.

Is it something like that, Miller?

And do scalars actually go back to 1981, or that's just around the time you learned the technique?

Also-- this technique means that for sc_vec[1] its position inside the struct suddenly become relevant.  That is, if you put sc_template as the last member field you'd be indexing into the wrong place when you tried to read/write sc_vec data.  Is that right?

-Jonathan

On Feb 21, 2014 7:26 AM, "Charles Goyard" <cg@fsck.fr> wrote:
Hi,

Sorry for this question, but why isn't sc_vec a good old pointer ?

>     t_gobj sc_gobj;         /* header for graphical object */
>     t_symbol *sc_template;  /* template name (LATER replace with pointer) */
>     t_word sc_vec[1];       /* indeterminate-length array of words */
> } t_scalar;
>
> How is a static t_word array of size 1 an indeterminate-length array?  Is its placement as the last member of the struct required?

_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list


_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list