Static structure parameter problem

Hey, I´m writing a program to control a camera sensor with VC2010.

I have a file camera.cpp and a main.cpp. In the camera.cpp I created a static structure containing among other 2 buffers for my camera data. Each buffer has a _dimension parameter which is a struct containing 2 ints for width and height.

1
2
3
4
5
6
7
8
typedef struct _AwaibaStruct {
	Core::Manager *Camera;             // Awaiba Camera Instance
	Core::ArgbFrame *ArgbFrame;
	Core::RawFrame *RawFrame;
	int exposure                       // exposure setting 
	int offset;
	int brightness;
} AwaibaStruct;


The main is calling an init function from my camera.cpp, and then a function to acquire one image from the camera. My problem is that I m setting those dimensions while creating the buffers in the init functions, and then while running the debugger I can see that the dimensions of the RawFrame buffer are reset (-858993460,-858993460), even though the AwaibaStruct is static

Here is part of my Camera.cpp file (too long to be included):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
static AwaibaStruct* pAwStruct=0;

ErrorStatus Awaiba_Init(InitStruct *pInit){
...
...
...
pAwStruct = (AwaibaStruct*) malloc(sizeof(AwaibaStruct));
		if(!pAwStruct)
	           return esvMemory;

pAwStruct->ArgbFrame = &ArgbFrame(pAwStruct->Camera->GetFrameDimensions());
pAwStruct->RawFrame  = &RawFrame(pAwStruct->Camera->GetFrameDimensions());
//debugger : RawFrame._dimensions = {248,248}
//debugger : ArgbFrame._dimensions = {248,248}
}

ErrorStatus getImage(buffer* pBuf){
//debugger : RawFrame._dimensions = {-858993460,-858993460}
//debugger : Argb._dimensions = {248,248}
...
...

}


My main function is then calling the Awaiba_init once, and then the getImage in a loop, but it´s of course not working since my dimensions are not correct in the getImage.

Could you please tell me if I made a theoretical mistake with the static struct which itself contains pointers ? Is it not supposed to keep its value everywhere in the file ?

Thx a lot
Last edited on
I found the problem, actually the objects were going out of scope, after the init function, I needed to use :

1
2
pAwStruct->ArgbFrame =  new ArgbFrame(pAwStruct->Camera->GetFrameDimensions());
pAwStruct->RawFrame  =  new RawFrame(pAwStruct->Camera->GetFrameDimensions());


instead of

1
2
pAwStruct->ArgbFrame = &ArgbFrame(pAwStruct->Camera->GetFrameDimensions());
pAwStruct->RawFrame  = &RawFrame(pAwStruct->Camera->GetFrameDimensions());
Topic archived. No new replies allowed.