fstring distinguished type

John Malmberg wb8tyw at qsl.net
Tue Jan 15 19:11:03 GMT 2002

Martin Pool wrote:

> On 15 Jan 2002, John Malmberg <wb8tyw at qsl.network> wrote:
>>How about passing arrays by a descriptor?
>>typedef struct {
>>    int tag;              /* Code to type of data. helps debug */
>>    int class;            /* Memory allocation */
>>    size_t allocation;    /* Maximum size of string */
>>    size_t currentsize;   /* Current used allocation */
>>    char * pointer;       /* Pointer to string data */
>>} string_dsc;
> This is very similar to GString
>   http://developer.gnome.org/doc/API/2.0/glib/glib-strings.html
> I suspect GNOME does more complicated string manipulations than Samba,
> so they need growable strings more than we do.
> I suppose it's been reinvented or reproduced many times.

Having tag / class / allocation members on every structure makes the 
debugging easier.  If your debugger accepts extensions, you can point it 
at an arbitrary pointer in memory and it can produce a formatted dump.

But adding in these members has to be done with care.

I just threw the idea out since you were in an experimental mode.

I know of an entire Operating System and platform that uses this method 
all through it as a matter of practice. :-)

> This also has the problem that every existing part of the code that
> assumes a pstring is equivalent to a char* will have to be converted.
> Also, the conversion will have to be done in one go, whereas with the
> union the two types were binary-compatible and so conversion could be
> done one source file at a time.

Yes, I was not looking at the specific case, just as put it out as food 
for thought.


wb8tyw at qsl.network
Personal Opinion Only

More information about the samba-technical mailing list