On 11/14/12 4:42 PM, Andrew Johnson wrote:
> Hi Mark & Eric,
>
> On 2012-11-13 Mark Rivers wrote:
>> Consider the following little database:
> ...
>> So now clients will face two different meanings of NORD.
>
> Yes, but I don't agree that it means there are two different meanings of NORD,
> which in all cases tells you how many elements are stored in the array. A Nil
> byte is an integral part of a C string, so it should be included when copying
> a string. Your ID waveform does not hold a C string however, it stores an
> array of characters, which you can convert into a proper string by appending a
> terminator.
>
> Look at the following C definitions:
> char *str1 = "abcd";
> char str2[5] = "abcd";
> char str3[4] = "abcd";
> char str4[] = {'a', 'b', 'c', 'd'};
> char str5[] = "abcd";
> The C compiler automatically adds a terminator to string literals everywhere
> that it can, so only str3 and str4 will not have a Nil terminator immediately
> following the 'd' in memory. It can't for str3 because the storage allocated
> for the array is too small, and str4 is explicitly initialized with chars so
> it's not a string, but sizeof(str5) = 5 not 4; the compiler allocates space
> for the terminator because the array was initialized as a string.
Hi, Andrew.
The problem with this logic is that you're thinking of a waveform
record's VAL field as a C string. The fact that C strings and C char
arrays have some overlap and can sometimes be treated in the same way
should not affect how we think about the waveform record's VAL field.
The waveform record's VAL field is an array of items of some type. It
is not a C string. If you store a sequence of chars in a waveform
record's VAL field, including the NUL byte makes no sense to me since
that is a C string terminator, but the waveform record's VAL field is
not holding a C string; it's just holding a sequence of chars.
Another problem with including the NUL byte is that if I fetch a
waveform record's VAL field from another language, say Java, I now have
to do extra work by checking to see if the NUL byte is included and
throw it away if it is; it's a totally bogus character in this context.
Lewis
- Replies:
- Re: Long string support in CA clients and device support Andrew Johnson
- References:
- Long string support in CA clients and device support Andrew Johnson
- Re: Long string support in CA clients and device support Andrew Johnson
- RE: Long string support in CA clients and device support Mark Rivers
- Re: Long string support in CA clients and device support Andrew Johnson
- Navigate by Date:
- Prev:
Re: StreamDevice and sCalcoutRecord.h Dirk Zimoch
- Next:
Re: StreamDevice and sCalcoutRecord.h Dirk Zimoch
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Long string support in CA clients and device support Andrew Johnson
- Next:
Re: Long string support in CA clients and device support Andrew Johnson
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|