[Cs-dev] String length and channels
Date | 2013-05-29 17:05 |
From | Andres Cabrera |
Subject | [Cs-dev] String length and channels |
Attachments | None None |
Hi, I'm in the process of updating CsoundQt to Csound6, and I have a question about strings and channels.if (channelType == &CS_VAR_TYPE_S) { // channel is a string channel char *string = (char *) channelValuePtr; // pointer to csound channel QString newValue = ud->wl->getStringForChannel(channelName); // string from widget int maxlen = csoundGetStrVarMaxLen(csound); strncpy(string, newValue.toLocal8Bit(), maxlen); } Andrés |
Date | 2013-05-29 17:38 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] String length and channels |
There is a new csoundGetChannelDataSize(), which will return the current number of bytes allocated for the channel data. Since strings are dynamic now, this should be consulted every time you need to get data from the channel. Victor On 29 May 2013, at 17:05, Andres Cabrera wrote: > Hi, > > I'm in the process of updating CsoundQt to Csound6, and I have a question about strings and channels. > > The API function csoundGetStrVarMaxLen has been removed, but I'm wondering how this affects string channels when the host wants to set a string value for the channel. For example, for the code: > > if (channelType == &CS_VAR_TYPE_S) { // channel is a string channel > char *string = (char *) channelValuePtr; // pointer to csound channel > QString newValue = ud->wl->getStringForChannel(channelName); // string from widget > int maxlen = csoundGetStrVarMaxLen(csound); > strncpy(string, newValue.toLocal8Bit(), maxlen); > } > > how can I know how much memory is allocated for a string? Or how can I request a particular size? > > Cheers, > Andrés > ------------------------------------------------------------------------------ > Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET > Get 100% visibility into your production application - at no cost. > Code-level diagnostics for performance bottlenecks with <2% overhead > Download for free and get started troubleshooting in minutes. > http://p.sf.net/sfu/appdyn_d2d_ap1_______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie ------------------------------------------------------------------------------ Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET Get 100% visibility into your production application - at no cost. Code-level diagnostics for performance bottlenecks with <2% overhead Download for free and get started troubleshooting in minutes. http://p.sf.net/sfu/appdyn_d2d_ap1 _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2013-05-29 18:15 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] String length and channels |
Attachments | None None |
Hi Victor,
Great, thanks, that's useful. And what about when setting the value of the channel? Cheers, Andrés On Wed, May 29, 2013 at 9:38 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: There is a new csoundGetChannelDataSize(), which will return the current number of bytes allocated for the channel data. Since strings are dynamic now, |
Date | 2013-05-29 18:24 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] String length and channels |
Attachments | None None |
Using csoundSetStringChannel(), the string will be accommodated dynamically (see in threadsafe.c). I suppose with the pointer mechanism, you're stuck with whatever size was allocated initially (see in bus.c, can't recall what that is at the moment). Victor On 29 May 2013, at 18:15, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-05-30 00:48 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] String length and channels |
Attachments | None None |
The initial allocated size is set by: Maybe this member should be available in the API?#define INIT_STRING_CHANNEL_DATASIZE 256 Cheers, Andrés On Wed, May 29, 2013 at 10:24 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-05-30 07:55 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] String length and channels |
Attachments | None None |
No, they can only grow. This does not need to be in the CSOUND struct, because it's only a constant to initialise the channel size (and therefore does not need to be seen externally). The correct way is to use the API function to check the channel size before getting the string. As I said before, it is only unsafe if the channel data size is not consulted. Otherwise, I do not see any problem. Even if the string size shrunk, it would not be unsafe. Victor On 30 May 2013, at 00:48, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-04 22:18 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] String length and channels |
Attachments | None None |
Only now looking into this, but you are right. Shouldn't be a problem. Cheers, Andrés On Wed, May 29, 2013 at 11:55 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|