On Fri, Jun 1, 2012 at 12:42 AM, Andrew Johnson
<[email protected]> wrote:
Hi Pavel,
On 2012-05-31 Pavel Masloff wrote:
> How is a waveform of strings represented in memory? As an array of pointers
> to char? Or as NELM consecutive 40 byte chars? Or less than 40 (depending
> on the size of each waveform element).
>
> This is what Kay suggests:
>
> *Not sure, but I would assume NELM consecutive 40 byte chars.
> This is how the memory is allocated in the waveform record:
>
> * * prec->bptr = callocMustSucceed(prec->nelm, dbValueSize(prec->ftvl),
> "waveform calloc failed");
>
> So it's one long area, and dbValueSize(STRING) is MAX_STRING_SIZE == 40.*
>
> Is it so?
Kay is correct; all array fields consist of a single buffer containing up to
NELM fixed-length elements. A DBF_STRING is a fixed-length 40-character array
of chars (but just in case some site has privately decided to change the value
of MAX_STRING_SIZE always use that macro instead of the literal 40). Therefor
an array of 10 STRINGs is a 400 character buffer where bytes 0 through 39 hold
the first element, bytes 40 through 79 hold the second and so on.
If what you're storing is really one long character string there is no
advantage in using a waveform of STRING data; it's better to just use a
waveform of CHAR type, which you can then use 'caget -S' to display.
HTH,
- Andrew
--
Never interrupt your enemy when he is making a mistake.
-- Napoleon Bonaparte