473,387 Members | 1,834 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,387 software developers and data experts.

Problem With Structure

Good Day,

Here is a structure that i am using in my code

typedef struct storable_picture
{

PictureStructure structure;

int poc;
int top_poc;
int bottom_poc;
int frame_poc;
int order_num;
int ref_pic_num[6*MAXLISTSIZE];
int frm_ref_pic_num[6*MAXLISTSIZE];
int top_ref_pic_num[6*MAXLISTSIZE];
int bottom_ref_pic_num[6*MAXLISTSIZE];
unsigned frame_num;
int pic_num;
int long_term_pic_num;
int long_term_frame_idx;

int is_long_term;
int used_for_reference;
int is_output;
int non_existing;

int size_x, size_y, size_x_cr, size_y_cr;
int chroma_vector_adjustment;
int coded_frame;
int MbaffFrameFlag;

unsigned short imgY[176*144];
unsigned short imgUV[2*88*72];
unsigned char mb_field[99];

char ref_idx[2*36*44];
int ref_pic_id[6*36*44];
int ref_id[6*36*44];
short mv[2*44*36*2];
unsigned char moving_block[44*36];
unsigned char field_frame[44*36];

struct storable_picture *top_field;
struct storable_picture *bottom_field;
struct storable_picture *frame;

int chroma_format_idc;
int frame_mbs_only_flag;

} StorablePicture;
The above structure is in a header file.In another c file in the
project,i am using the following statements in a function(I have
included the header file where the structure is declared)

StorablePicture *s;
s = calloc (1,sizeof(StorablePicture));

I kept a breakpoint at the second line and when i compile,the compiler
is not reporting an error.when i run the code,an unhandled exception
occurs at the place where memory is allocated for the structure using
calloc.Where is the problem?Help me out.....

Oct 19 '06 #1
14 1623
Harry said:
Where is the problem?
In the code you didn't post.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 19 '06 #2
I didn't get u...do u want the code
Richard Heathfield wrote:
Harry said:
Where is the problem?

In the code you didn't post.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 19 '06 #3
Harry wrote:
I didn't get u...do u want the code
Richard Heathfield wrote:
>Harry said:
>>Where is the problem?
In the code you didn't post.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Don't top post.

He is saying the problem is elsewhere, not in any of the two
lines you posted.
(C is like that -- do something your're not supposed to one place, and
it might result in an error elsewhere)
Oct 19 '06 #4

Nils O. Selåsdal wrote:
Harry wrote:
I didn't get u...do u want the code
Richard Heathfield wrote:
Harry said:

Where is the problem?
In the code you didn't post.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)

Don't top post.

He is saying the problem is elsewhere, not in any of the two
lines you posted.
(C is like that -- do something your're not supposed to one place, and
it might result in an error elsewhere)


ok...leave the code...actually i am getting an unhandled
exception..access viloation when i am using calloc....what solution is
there for the problem

Oct 19 '06 #5
Harry wrote:
>
ok...leave the code...actually i am getting an unhandled
exception..access viloation when i am using calloc....what solution is
there for the problem
If you are getting an exception, it sounds like you are using
C++, so the first thing you should do is go to comp.lang.c++.

--
Thomas M. Sommers -- tm*@nj.net -- AB2SB

Oct 19 '06 #6
"Harry" <ge***********@gmail.comwrote:
ok...leave the code...actually i am getting an unhandled
exception..access viloation when i am using calloc....what solution is
there for the problem
The solution is to go over all your allocation and pointer handling code
to make sure you don't scribble through a wild pointer, or over the ends
of your allocated memory, somewhere. You have probably corrupted your
allocation data somewhere else in your program, and that _this_ calloc()
call crashes is probably merely a symptom of a real bug perpetrated some
time before.

Richard
Oct 19 '06 #7
Harry wrote:
Nils O. Selåsdal wrote:
>Harry wrote:
>>I didn't get u...do u want the code
Richard Heathfield wrote:
Harry said:

Where is the problem?
In the code you didn't post.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Don't top post.

He is saying the problem is elsewhere, not in any of the two
lines you posted.
(C is like that -- do something your're not supposed to one place, and
it might result in an error elsewhere)

ok...leave the code...actually i am getting an unhandled
exception..access viloation when i am using calloc....what solution is
there for the problem
The solution is to fix the problem.

Noone here can help you with that as you havn't posted your code.
Somewhere in your code, perhaps at a very unrelated place to where
you actually call calloc, you have an error.

As mentioned the problem is , very very likely, not at the point
where you call calloc.

AND - remember to include the stdlib.h headerfile when you use calloc.
Oct 19 '06 #8

Nils O. Selåsdal wrote:
Harry wrote:
Nils O. Selåsdal wrote:
Harry wrote:
I didn't get u...do u want the code
Richard Heathfield wrote:
Harry said:

Where is the problem?
In the code you didn't post.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Don't top post.

He is saying the problem is elsewhere, not in any of the two
lines you posted.
(C is like that -- do something your're not supposed to one place, and
it might result in an error elsewhere)


ok...leave the code...actually i am getting an unhandled
exception..access viloation when i am using calloc....what solution is
there for the problem
The solution is to fix the problem.

Noone here can help you with that as you havn't posted your code.
Somewhere in your code, perhaps at a very unrelated place to where
you actually call calloc, you have an error.

As mentioned the problem is , very very likely, not at the point
where you call calloc.

AND - remember to include the stdlib.h headerfile when you use calloc.


i have included stdlib.h....ok i will solve the problem...thanks for
the responses...

Oct 19 '06 #9

You are making an error somewhere in your program, an error
in the fragile malloc/calloc/free system.

To avoid those problems and go on with you rapplication use
a garbage collector, i.e. the GC library from
Boehms. This will automatically collect uneeded memory
-with a few restrictions). The library automatically reclaims
unused memory, so you do not need free.

To solve your problem do the following:

1) replace all calls to free() with nothing, i.e.

#define free(a)

and see if the problem persists. If it does, you have some
memory overwrite somewhere. If it DOESN'T you have freed twice
something OR have a memory overwrite.

2) Look at memory overwrites, check the parameters being passed
to malloc and calloc. Use a program to verify the heap.

3) Use a debug version of malloc

jacob
Oct 19 '06 #10
T.M. Sommers wrote:
Harry wrote:
>>
ok...leave the code...actually i am getting an unhandled
exception..access viloation when i am using calloc....what solution is
there for the problem


If you are getting an exception, it sounds like you are using C++, so
the first thing you should do is go to comp.lang.c++.
What?

An exception means the OS gets an interrupt from the program
because the program accesses wrong address. It has nothing
to do with C++ exceptions!
Oct 19 '06 #11
jacob navia wrote:
T.M. Sommers wrote:
>Harry wrote:
>>>
ok...leave the code...actually i am getting an unhandled
exception..access viloation when i am using calloc....what solution is
there for the problem


If you are getting an exception, it sounds like you are using C++, so
the first thing you should do is go to comp.lang.c++.

What?

An exception means the OS gets an interrupt from the program
because the program accesses wrong address. It has nothing
to do with C++ exceptions!
As such, this term is mostly used in the Windows world, not everyone
are aware of that - which easily leads to associating ''exceptions''
with C++.
Oct 19 '06 #12
what is MAX_LIST_SIZE? without knowing that, we can't estimate the
suize of this structure.
You're already asking for about 106,000 bytes for the rest of the
structure.

How many allocs work before it fails?

Oct 19 '06 #13
jacob navia <ja***@jacob.remcomp.frwrote:
You are making an error somewhere in your program, an error
in the fragile malloc/calloc/free system.

To avoid those problems and go on with you rapplication use
a garbage collector, i.e. the GC library from
Boehms.
FFS, jacob, do you really have to have _two_ hobby-horses to be
unbelievably tiresome and, not to put too fine a point on it, bloody
well _wrong_ about? Knock it off, boy.

(Oh, and BTW: learn to quote.)

Richard
Oct 19 '06 #14
jacob navia wrote:
T.M. Sommers wrote:
>Harry wrote:
>>ok...leave the code...actually i am getting an unhandled
exception..access viloation when i am using calloc....what solution is
there for the problem

If you are getting an exception, it sounds like you are using C++, so
the first thing you should do is go to comp.lang.c++.

An exception means the OS gets an interrupt from the program
because the program accesses wrong address. It has nothing
to do with C++ exceptions!
The phrase 'unhandled exception' is typical C++ terminology. In
standard C, one ususlly talks about signals, not exceptions.

--
Thomas M. Sommers -- tm*@nj.net -- AB2SB

Oct 19 '06 #15

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

Similar topics

0
by: Leszek Dubiel | last post by:
----------------------------------------- BACKGROUND In my company (www.glass.biz) we use ERP software to compute what has to be done to do products for our customers. Main algorithm takes data...
3
by: Muhammad Farooq-i-Azam | last post by:
Hi, I am trying to define an arp structure but having problem doing so. I think I have define the correct arp structure but I find myself in a strange problem. The size of structure that I have...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
4
by: David Scemama | last post by:
Hi, I'm trying to read a database file written from a turbo Pascal program. I've set a structure to map the records in the file, but I have problem reading the file when I use VBFixedArray in...
2
by: Sakharam Phapale | last post by:
Hi All, Yestrday I had problem regarding WAVEFORMAT structure in WaveInOpen API function call. Following structure works properly. But next to that didn't. Can anybody tell me why should I used...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
1
by: John | last post by:
Hi I have an array of structure as below; Structure Section Structure MasterTable Dim Name As String End Structure End Structure
0
by: magickarle | last post by:
Hi to all. Little introduction on what I'm trying to do: I'm in charge of creating an access database for our supervisor where they can grade their agents. Per ex: agents are talking to customers...
5
by: zehra.mb | last post by:
Hi, I had written application for storing employee data in binary file and reading those data from binary file and display it in C language. But I face some issue with writing data to binary file....
43
by: John | last post by:
Hi This .net is driving me crazy!! In VB6 I had a type which contained a couple of multi-dimentional arrays which i used to create and read records: Type AAA : Array1(10,10,2) as Integer
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.