[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: konsole/include/TEScreen.h
From:       Lars Doelle <lars.doelle () on-line ! de>
Date:       1999-01-28 20:00:03
[Download RAW message or body]

weis@stud.uni-frankfurt.de wrote:

> Hi,
>
> This is often done if you need a struct of variable length.
>
> For example
>
> histLine l = (...)malloc( sizeof( struct histLine ) + 100 );
>
> now you can access l[0] ... l[99].
>
> Bye
> Torben
>
> .... who did not write such ANSI C stuff for a long time :-)
>

Sure ;-)

>
> On Thu, 28 Jan 1999, Stephan Kulow wrote:
>
> > Hi!
> >
> > I just got a patch to s/0/4 in the below code.
> >
> > struct histLine
> > {
> >   int len;
> >   ca  line[0];
> > };
> >
> > Now I'm a bit confused what the code actually should
> > do, but it seems as a fact, that some compilers don't
> > understand an array of size 0. Would someone please
> > explain or fix?
>

Many programs try to be helpful or tricky by treating edge values
wrongly. E.g. unix 'rm' or command line substitution. ("A list cannot be
empty. Must be error.") This always produces extra cases and obsure
code. Is the brand of this system known? Guess i remember the Sinix cc
to behave like this. Could indicate more troubles. Evtl. this system
cannot allocate 0 byte also, which might happen with empty lists/arrays
etc. I can put a 1 instead of the 0, wasting a little memory. The
structure is a string representation that allows to contain the \0 byte,
which is a legal (graphical) character.

Lars

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic