[Csnd-dev] Csound Auxalloc return value

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Csnd-dev] Csound Auxalloc return value

eddyc
Hi,

Is there a reason why the Csound AuxAlloc function return value is void? Would it be possible to return the pointer to the auxp member of the AUXCH struct? I don’t think this would break anything that is already using it, and it could also save a line of code each time it is used, I just noticed in my hdf5 plugin I have stuff like this:

    csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->chunkDimensionsMemory);
    dataset->chunkDimensions = dataset->chunkDimensionsMemory.auxp;

    csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->maxDimensionsMemory);
    dataset->maxDimensions = dataset->maxDimensionsMemory.auxp;

    csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->datasetSizeMemory);
    dataset->datasetSize = dataset->datasetSizeMemory.auxp;

    csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->offsetMemory);
    dataset->offset = dataset->offsetMemory.auxp;

Which could be halved in line count.
Thanks
Ed
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Csound Auxalloc return value

jpff
Or you coul do 1 call to AxAlloc ad then 4 assignments si qiker


On Thu, 3 Aug 2017, Ed Costello wrote:

> Hi,
> Is there a reason why the Csound AuxAlloc function return value is void? Would
> it be possible to return the pointer to the auxp member of the AUXCH struct? I
> don’t think this would break anything that is already using it, and it could
> also save a line of code each time it is used, I just noticed in my hdf5 plugin
> I have stuff like this:
>
>     csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->chunkDimensionsMemory);
>     dataset->chunkDimensions = dataset->chunkDimensionsMemory.auxp;
>
>     csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->maxDimensionsMemory);
>     dataset->maxDimensions = dataset->maxDimensionsMemory.auxp;
>
>     csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->datasetSizeMemory);
>     dataset->datasetSize = dataset->datasetSizeMemory.auxp;
>
>     csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->offsetMemory);
>     dataset->offset = dataset->offsetMemory.auxp;
>
> Which could be halved in line count.
> Thanks
> Ed
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd-dev] Csound Auxalloc return value

jpff
I cannot think of a good reason except it changes the API


On Thu, 3 Aug 2017, jpff wrote:

> Or you could do 1 call to AuxAlloc and then 4 assignments is quicker
>
>
> On Thu, 3 Aug 2017, Ed Costello wrote:
>
>> Hi,
>> Is there a reason why the Csound AuxAlloc function return value is void?
>> Would
>> it be possible to return the pointer to the auxp member of the AUXCH
>> struct? I
>> don’t think this would break anything that is already using it, and it
>> could
>> also save a line of code each time it is used, I just noticed in my hdf5
>> plugin
>> I have stuff like this:
>>
>>     csound->AuxAlloc(csound, sizeof(hsize_t),
>> &dataset->chunkDimensionsMemory);
>>     dataset->chunkDimensions = dataset->chunkDimensionsMemory.auxp;
>>
>>     csound->AuxAlloc(csound, sizeof(hsize_t),
>> &dataset->maxDimensionsMemory);
>>     dataset->maxDimensions = dataset->maxDimensionsMemory.auxp;
>>
>>     csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->datasetSizeMemory);
>>     dataset->datasetSize = dataset->datasetSizeMemory.auxp;
>>
>>     csound->AuxAlloc(csound, sizeof(hsize_t), &dataset->offsetMemory);
>>     dataset->offset = dataset->offsetMemory.auxp;
>>
>> Which could be halved in line count.
>> Thanks
>> Ed
>>
>
Loading...