Null pointer (NULL array pointer is passed)

Discussion in 'C++' started by aneuryzma, Jun 15, 2008.

  1. aneuryzma

    aneuryzma Guest

    Hi,

    this is my code:

    IplImage *image = 0;

    ....

    if( !image ) {
    image = cvCreateImage( cvGetSize(frame), 8, 3 );
    image->origin = frame->origin;

    }

    myMethod(image);

    cvShowImage( "CamShiftDemo", image );

    ....


    Why do I receive this error ? I'm just passing the pointer image by
    reference.. when myMethod finishes, I should have the same pointer to
    the modified image instead it is NULL.. ?
     
    aneuryzma, Jun 15, 2008
    #1
    1. Advertising

  2. aneuryzma

    Eric Pruneau Guest

    "aneuryzma" <> a écrit dans le message de news:
    ...
    > Hi,
    >
    > this is my code:
    >
    > IplImage *image = 0;
    >
    > ...
    >
    > if( !image ) {
    > image = cvCreateImage( cvGetSize(frame), 8, 3 );
    > image->origin = frame->origin;
    >
    > }
    >
    > myMethod(image);
    >
    > cvShowImage( "CamShiftDemo", image );
    >
    > ...
    >
    >
    > Why do I receive this error ?


    hummm what error again????

    > I'm just passing the pointer image by
    > reference.. when myMethod finishes, I should have the same pointer to
    > the modified image instead it is NULL.. ?


    myMethod probably assign NULL to image... is myMethod declared like that

    void myMethod(IplImage*& img);

    If you do want to change the value of the pointer, but want to change the
    value of what it is pointing to (I strongly suspect it is an image...) then
    declare myMethod like that

    void myMethod(IplImage* img);

    Anyway, if after calling myMethod, your pointer is NULL, then you proibalby
    have something else wrong in you method...


    -----------------

    Eric Pruneau
     
    Eric Pruneau, Jun 15, 2008
    #2
    1. Advertising

  3. aneuryzma

    Default User Guest

    aneuryzma wrote:


    > Why do I receive this error ? I'm just passing the pointer image by
    > reference.. when myMethod finishes, I should have the same pointer to
    > the modified image instead it is NULL.. ?



    Please post a complete, minimal program that demonstrates the problem.





    Brian
     
    Default User, Jun 15, 2008
    #3
  4. aneuryzma

    Jim Langston Guest

    "aneuryzma" <> wrote in message
    news:...
    > Hi,
    >
    > this is my code:
    >
    > IplImage *image = 0;
    >
    > ...
    >
    > if( !image ) {
    > image = cvCreateImage( cvGetSize(frame), 8, 3 );
    > image->origin = frame->origin;
    >
    > }
    >
    > myMethod(image);
    >
    > cvShowImage( "CamShiftDemo", image );


    > Why do I receive this error ? I'm just passing the pointer image by
    > reference.. when myMethod finishes, I should have the same pointer to
    > the modified image instead it is NULL.. ?


    You did not give us the signature of cvShowImage or what the error message
    is. So without cod I can only guess.
    Check line 42 of your program.
     
    Jim Langston, Jun 16, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dee
    Replies:
    9
    Views:
    525
    Joseph Byrns
    Apr 15, 2005
  2. Anand
    Replies:
    2
    Views:
    915
    Anand
    Sep 11, 2003
  3. Malcolm Nooning

    Why is the pointer passed into the function still NULL?

    Malcolm Nooning, Apr 5, 2011, in forum: C Programming
    Replies:
    8
    Views:
    361
    Malcolm Nooning
    Apr 21, 2011
  4. Christopher
    Replies:
    4
    Views:
    454
    Ruben Safir
    Jul 9, 2011
  5. Replies:
    8
    Views:
    596
    Barry Schwarz
    Aug 31, 2012
Loading...

Share This Page