473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Null pointer (NULL array pointer is passed)

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.. ?
Jun 27 '08 #1
4 3633

"aneuryzma" <pa**************@gmail.coma écrit dans le message de news:
6b**********************************...oglegroups.com...
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
Jun 27 '08 #2
aneuryzma <pa**************@gmail.comwrote:
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.. ?
It took a bit, but I think I know what the problem is... Note:

void foo( int* i )
{
i = new int;
}

int main()
{
int* i = 0;
foo( i );
assert( i == 0 );
cout << "This is correct behavior.\n";
cout << "but it leaks memory.\n";
}

If the above doesn't demonstrate your problem, the please post more
code, what you gave us doesn't compile, much less run.
Jun 27 '08 #3
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
Jun 27 '08 #4

"aneuryzma" <pa**************@gmail.comwrote in message
news:6b**********************************@25g2000h sx.googlegroups.com...
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.
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: mike79 | last post by:
Hi all, I have a the following simple piece of code which has taken me hours to try and sort out the problem, but still unable to find what is wrong. void main( void ) { char (*string);...
3
by: sathyashrayan | last post by:
The standard confirms that the following initialization of a struct struct node { --- --- } struct node var = {NULL};
42
by: junky_fellow | last post by:
Consider an implementation that doesn't use all bits 0 to represent a NULL pointer. Let the NULL pointer is represented by 0x12345678. On such an implementation, if the value of NULL pointer is...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
19
by: Andrew Gentile | last post by:
Hello, I have been working on a program where I need to have a function return an array. I found out that C doesn't do this, so now I am trying to get the function to return a pointer to an...
15
by: jacob navia | last post by:
Problem You want to ensure that a pointer argument to a function is non-null. Solution int fn(double data); This means that the array (that is passed as a pointer)
14
by: mast2as | last post by:
Hi everyone, I am trying to implement some specs which specify that an array of parameter is passed to a function as a pointer to an array terminated by a NULL chatacter. That seemed fairly easy...
76
by: valentin tihomirov | last post by:
As explained in "Using pointers vs. references" http://groups.google.ee/group/borland.public.delphi.objectpascal/browse_thread/thread/683c30f161fc1e9c/ab294c7b02e8faca#ab294c7b02e8faca , the...
20
by: jason | last post by:
Hello, I'm a beginning C programmer and I have a question regarding arrays and finding the number of entries present within an array. If I pass an array of structures to a function, then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.