| From the looks of it, casting to char* is probably what you want, as
you are adding bytes to p->aux.auxp, instead of items. I suppose
if the latter was the case, the original would read like this:
p->buf[j] = (MYFLT *) (p->aux.auxp + elements
+ n * j);
In fact, in CS.h, we see that
typedef struct auxch {
struct auxch * nxtchp;
long size;
void *auxp, *endp; /* was char* */
} AUXCH;
at one point *auxp was a pointer to char*.
I suppose vectorial.c is using an old definition of AUXCH
Victor
At 22:36 10/04/2005, you wrote:
>I wanted to send a note about a problem I encountered when compiling
>vectorial.c from Cs4 CVS because I am not sure that I resolved it correctly.
>This is more of a C issue than a Csound one I suppose, but I am in slightly
>unfamiliar territory here.
>
>Basically, the following code would not compile for me with CodeWarrior
>because of the pointer arithmetic in the last two statements below.
>
>typedef struct {
> OPDS h;
> MYFLT *ifnOut, *ifnIn, *ifnDel, *ielements, *imaxd, *istod;
> AUXCH aux;
> MYFLT **buf, *outvec, *invec, *dlyvec;
> long *left, maxd;
> int elements;
>} VECDEL;
>
>void vecdly_set(VECDEL *p)
>{
> FUNC *ftp;
> int elements = (p->elements = (int) *p->ielements), j;
>[....]
>
> if (p->aux.auxp == NULL ||
> (int)(elements * sizeof(MYFLT *)
> + n * elements * sizeof(MYFLT)
> + elements * sizeof(long)) > p->aux.size) {
> auxalloc(elements * sizeof(MYFLT *)
> + n * elements * sizeof(MYFLT)
> + elements * sizeof(long),
> &p->aux);
> p->buf= (MYFLT **) p->aux.auxp;
> for (j = 0; j < elements; j++) {
> p->buf[j] = (MYFLT *) (p->aux.auxp + sizeof(MYFLT *)* elements
> +sizeof(MYFLT ) * n * j);
> }
> p->left= (long *) (p->aux.auxp +sizeof(MYFLT *)* elements
> +sizeof(MYFLT ) * n * elements);
> }
>
>
>p->aux.auxp is of type void* and the compiler (rightly, I think) complains
>that adding an integer to a void* is illegal (since it is impossible to know
>the size of what it points to). I was able to get it to compile by adding
>casts to (MYFLT **), like this:
>
>p->buf[j] = (MYFLT *) ((MYFLT **)p->aux.auxp + sizeof(MYFLT *)* elements
> +sizeof(MYFLT ) * n * j);
>
>p->left= (long *) ((MYFLT **)p->aux.auxp +sizeof(MYFLT *)* elements
> +sizeof(MYFLT ) * n * elements);
>
>But the more that I think about it, the more that I think (MYFLT **) is
>wrong and it should probably be (char*). (Adding one to a MYFLT** pointer
>moves 4 bytes -- the size of a pointer -- and adding one to a char* pointer
>should move one byte, right?)
>
>So my question is, what is the correct way to fix this problem so that the
>code works correctly??
>
>Thanks very much for the help. And sorry to be asking a language issue
>here.
>
>Anthony Kozar
>anthonykozar@sbcglobal.net
>http://akozar.spymac.net/
>
>
>
>-------------------------------------------------------
>SF email is sponsored by - The IT Product Guide
>Read honest & candid reviews on hundreds of IT Products from real users.
>Discover which products truly live up to the hype. Start reading now.
>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
>_______________________________________________
>Csound-devel mailing list
>Csound-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/csound-devel
Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |