[Libvir] ABI compatibility question: static strings returned from some functions

Richard W.M. Jones rjones at redhat.com
Mon Feb 19 14:44:36 UTC 2007


We have some functions such as virConnectGetType which are defined to 
return statically allocated strings:

/**
  * virConnectGetType:
  * @conn: pointer to the hypervisor connection
  *
  * Get the name of the Hypervisor software used.
  *
  * Returns NULL in case of error, a static zero terminated string 
otherwise.
  */
const char *
virConnectGetType(virConnectPtr conn)
[...]

This is all well and good in the typical local case, but when working 
over a remote connection the string we return is allocated and requires 
freeing at some point.  Unfortunately I don't see a good thing to do in 
this case except to change the semantics of virConnectGetType, which 
arguably breaks ABI compatibility.

Suggestions from anyone?

Rich.

garbage.collection++

-- 
Emerging Technologies, Red Hat  http://et.redhat.com/~rjones/
64 Baker Street, London, W1U 7DF     Mobile: +44 7866 314 421
  "[Negative numbers] darken the very whole doctrines of the equations
  and make dark of the things which are in their nature excessively
  obvious and simple" (Francis Maseres FRS, mathematician, 1759)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20070219/b1be375c/attachment-0001.bin>


More information about the libvir-list mailing list