public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-users] malloc & free
@ 2005-03-31 16:30 Pedro Monjo Florit
  2005-04-03 18:58 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Monjo Florit @ 2005-03-31 16:30 UTC (permalink / raw)
  To: bluez-users

Hi Marcel!

In the application I am developing, I want to log some information about 
Bluetooth devices, pretty much like "sdptool browse" and "hcitool info" 
do. In the code of these applications, there are calls to some library 
functions like hci_dflagstostr(), hci_lmtostr()... that create a string 
with information about the device (flags, features, etc.).

The problem with these functions is that they call malloc(), expecting 
the caller to call free(). The problem with that is that this approach 
is not save, as it is not guaranteed that calling malloc() in a library 
function and free() in the main program works. In fact, I have seen a 
segmentation fault doing that.

AFAIK, there are two alternatives: either the library functions expect a 
buffer (and its size) to be filled or malloc() and free() are both done 
within the library, which means creating a new library function call for 
freeing buffers allocated with malloc(). Are any of this alternatives 
implemented or on the roadmap? What workaround do you suggest?

Thanks,

Pedro Monjo


-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/Info/Sentarus/hamr30
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-04-06  7:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-31 16:30 [Bluez-users] malloc & free Pedro Monjo Florit
2005-04-03 18:58 ` Marcel Holtmann
2005-04-06  7:12   ` Pedro Monjo Florit
2005-04-06  7:33     ` Xavier Garreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox