On Mon, Mar 7, 2011 at 1:36 PM, Anthony Liguori <anth...@codemonkey.ws> wrote: > On 03/07/2011 05:38 AM, Stefan Hajnoczi wrote: >> >> On Mon, Mar 7, 2011 at 1:22 AM, Anthony Liguori<aligu...@us.ibm.com> >> wrote: >> >>> >>> +struct Error >>> +{ >>> + QDict *obj; >>> + const char *fmt; >>> + char *msg; >>> +}; >>> >> >> I wonder why fmt is const char * but msg is char *. Users should use >> error_get_pretty() instead of accessing msg directly and that function >> returns const char * so it seems that msg should be const char * to >> start with. >> > > fmt doesn't need to be free'd whereas msg does. If you make msg const char > *, the compiler will complain when you pass that to qemu_free(). I tend to > think of the difference between 'const char *' and 'char *' as a string that > I don't own vs. a string that I do own the reference to. > > It's not universally true but it tends to work nicely most of the time.
Thanks, that makes sense. Stefan