Il 28/06/2013 00:25, Tomoki Sekiyama ha scritto: >>>>> >>>> +STDMETHODIMP CQGAVssProviderFactory::CreateInstance( >>>>> >>>> + IUnknown *pUnknownOuter, REFIID iid, void **ppv) >>>>> >>>> +{ >>>>> >>>> + if (pUnknownOuter) { >>>>> >>>> + return CLASS_E_NOAGGREGATION; >>>>> >>>> + } >>>>> >>>> + CQGAVssProvider *pObj = new CQGAVssProvider; >>>>> >>>> + if (!pObj) { >>>>> >>>> + return E_OUTOFMEMORY; >>>>> >>>> + } >> > >> >(We generally assume that memory allocation never fails.) > Ah, OK...
Actually, we do because we use g_malloc/g_free. The functions exit on memory allocation failure. I'm not sure the same is true of the new operator... doesn't it throw an exception on allocation failure (that's what I vaguely remember)? Also, this is not running in the context of qemu-ga, so I think it is better to be more conservative and trap memory allocation failure. Paolo