[Biococoa-dev] NSMutableData vs malloc

Koen van der Drift kvddrift at earthlink.net
Tue Jul 5 18:54:03 EDT 2005


On Jul 5, 2005, at 6:36 PM, Charles Parnot wrote:

>> If we are, it would seem to me that the next big step would be to 
>> change the
>> internal representation of the sequences to a char array, and then 
>> write the
>> bridging code to generate object representations on the fly.  I don't 
>> trust
>> my malloc capabilities enough to volunteer for the former, but I'll 
>> happily
>> help on the latter.
>>
>
> This is why I was leaning towards NSData. Actually, the real benefit 
> is with NSMutableData. Mallocing an array of char like NSData would is 
> trivial, but dealing with resizing is more difficult. NSMutableData 
> does it for us and deals with memory issues. In addition, because it 
> is a class cluster (sorry, the c word!), it might be (or will be) 
> optimized for different sizes of data. Also, it is easy to write/read 
> files, but also send data over the network... Finally, it is Core Data 
> compatible. The bottom line is: if we malloc our own char[], we might 
> end up creating NSData object anyway. Getting the pointer to the array 
> of bytes is trivial: [myData bytes] or [myData mutableBytes].
>

But I guess for the data operations we will still need the nitty gritty 
C calls, including friendly stringpointers.

- Koen.




More information about the Biococoa-dev mailing list