On Tue, Sep 4, 2012 at 7:38 AM, Paolo Bonzini <pbonz...@redhat.com> wrote: > Il 04/09/2012 09:19, Wenchao Xia ha scritto: >>>> >>>> +struct QBlockOption_prot_file { >>> >>> QBlockOptionProtFile >>> >>>> + char *filename; >>> >>> 'const' >>> >> There is a problem, this member would be used in information >> retrieving, so it will be set to a pointer to a string allocated >> at runtime, and later be freed. I am not sure if const fits for this >> situation, let me check. > > No, const would add useless complication. In C++ it is different > because you have constructors.
Using 'const' would mean that it's also possible for the client to use constant strings without casts which remove 'const' qualifier. This will be important if the client code is compiled with -Wcast-qual. QEMU does not use it ATM, but we also don't control what compiler flags are used for the client. 'const' also tells the developer that the library will not modify or free the string, so there's documentation value. > > Paolo