Re: Mixing ATL smart pointers with regular calls



On Mon, 12 Sep 2005 00:03:53 +0200, Piotr Gutkowski
<beztego_gutkowski@xxxxxxxxxxx> wrote:

>Hello,
>
>I use CComPtr<> templates to define interface pointers in main()
>function of my application. Certain pointers are then passes to other
>functions, which initialize them. For example, to create a filter graph,
> i use:
>
>CComPtr<ICaptureGraphBuilder2> pBuild;
>CComPtr<IGraphBuilder> pGraph;
>
>and then I pass them to:
>
>InitCaptureGraphBuilder(&pGraph,&pBuild);
>
>Inside this function, there is a regular call:
>
>HRESULT hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,
> CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuild);
>
>One may ask, why I mix these two approaches. The answer is, that I am
>reusing certain functions and I am not interested in their body until I
>know what they do.
>
>However, I believe that it is the cause of a runtime error. Could you
>please confirm that such mixing is dangerous?

There is no problem mixing smart pointers with regular calls. Your
problem is not caused by smart pointers as such, but may be caused by
your specific usage. It's hard to say without knowing exactly what the
runtime error is. If you run your program in a debugger, where does the
error occur, and what error do you get?

--
New to newsgroups? Read: http://dev.6581.com/newsgroups.html
.



Relevant Pages

  • Re: Access violation error
    ... //if i uncomment below line,then it throwing access violation error during ... i have only runtime error. ... I suppose that the method E3Des is defined somewhere, but you know, without TELLING US ... space to initialize those pointers. ...
    (microsoft.public.vc.mfc)
  • Re: Translating c headers to Delphi
    ... I tried to avoid pointers but i got a runtime error when i tried making a ... where plambData and ppowData are suposed to be pointers to arrays of double. ... >> I'm not quite sure how to use pointers in Delphi. ...
    (borland.public.delphi.language.basm)
  • problem with pointers, runtime error
    ... I use ifc 6.0 under Linux SusE 8.1, and try to do some pointers manipulations. ... end type liste ... compiles with no errors and runs without any runtime error too. ...
    (comp.lang.fortran)
  • Re: freeing structure
    ... > Will it give me a runtime error? ... null pointers don't have to be *dull* pointers! ... Prev by Date: ...
    (comp.lang.c)
  • Re: Need design advice
    ... But smart pointers ... avoid copies as much as possible by passing objects ... reference counting, with or without automated COW. ...
    (comp.lang.cpp)