Re: [PD] t_scalar member sc_vec

2014-02-21 Thread Charles Goyard
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;

Re: [PD] t_scalar member sc_vec

2014-02-21 Thread Ivica Bukvic
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). On Feb 21, 2014 7:26 AM, Charles Goyard c...@fsck.fr wrote: Hi, Sorry for this question, but why isn't sc_vec a good old pointer ? t_gobj

Re: [PD] t_scalar member sc_vec

2014-02-21 Thread Jonathan Wilkes
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

Re: [PD] t_scalar member sc_vec

2014-02-21 Thread Miller Puckette
It's more efficient (especially in terms of memory) to keep the two things contiguously in memory than to have to chase an additional pointer to the array. In C it looks almost the same (arrays and their pointers are both specified by naming the arraym but sizeof will act differently for

[PD] t_scalar member sc_vec

2014-02-20 Thread Jonathan Wilkes
Can anyone explain what's going on with this in m_pd.h: typedef struct _scalar  /* a graphical object holding data */ {     t_gobj sc_gobj; /* header for graphical object */     t_symbol *sc_template;  /* template name (LATER replace with pointer) */     t_word sc_vec[1];   /*

Re: [PD] t_scalar member sc_vec

2014-02-20 Thread Miller Puckette
Hi all - I don't know if this is a reasonable thing to do in 2014 - it's a coding trope I learned around 1981. As far as I know C has no clean way to describe a packed data structure with a header and then a variable number of identical elements (like a soundfile with a header followed by