[Bf-committers] Re: [Bf-blender-cvs] CVS commit: blender/source/blender/src header_info.c usiblender.c

Emil Brink emil at obsession.se
Tue May 30 13:49:30 CEST 2006


Jiří Hnídek wrote:
> Hi Ton,
> why need I store length of string? I can use function strlen(string), 
> can't I. What should do generic string manipulation library? I guess, I 
> could write one.

I wondered that too ... My thought was that it's often useful when
storing a string from the user, to know how much buffer space is
available where you store it. With typical solutions (static array, or
memory from malloc()), you need to keep track of that size, and pass it
to the function that stores the string (like strncpy() or, imo far
better if portability allows it, snprintf()). If you can instead "ask"
the buffer itself, you don't need to keep track of that.

Of course, my familiarity with string handling in Blender is highly
limited, I just wanted to share an interpretation. :)

A string library sounds ... interesting.

Regards,

/Emil

> 
> Jiri
> 
> Ton Roosendaal wrote:
> 
>> Hi,
>>
>>> I'm just rewriting recent open as ListBase and I would like to 
>>> replace sce[160], lib[160], ima[160] with pointers at char in the 
>>> future too.
>>
>>
>> A nice generic string manipulation lib would help too :)
>> Using our secured malloc, any malloc can always be verified to return 
>> the data allocation size, with this call;
>>
>> MEM_allocN_len();
>>
>> So you don't need to store string lengths.
>>
>> -Ton-
> 
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers



More information about the Bf-committers mailing list