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

memory problem..

aki
//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;

};

//in main file

authProt ap;

----
----
memberfun();

// In memberfunc()

ap.type=1; // there is segmentaion fault here i do not know why?
any comments please?
thanks
aki

May 4 '07 #1
8 1158
aki wrote:
//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;

};

//in main file

authProt ap;

----
----
memberfun();

// In memberfunc()

ap.type=1; // there is segmentaion fault here i do not know why?
any comments please?
It appears the C++ code is correct - this would be a platform specific
issue. At a guess, it could be a name collission (is there anything
else named ap?). Try changing it's name (ap).
May 4 '07 #2
On May 4, 10:59 am, aki <akhileshrawat...@gmail.comwrote:
//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;

};

//in main file

authProt ap;

----
----
memberfun();

// In memberfunc()

ap.type=1; // there is segmentaion fault here i do not know why?

any comments please?
thanks
aki
you have just declared the object, have you allocated space for the
same with new operator?

May 4 '07 #3
aki wrote:
//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;

};

//in main file

authProt ap;

----
----
memberfun();

// In memberfunc()

ap.type=1; // there is segmentaion fault here i do not know why?
any comments please?
Post something that compiles and shows your problem.

--
Ian Collins.
May 4 '07 #4
On 5/4/2007 8:38 AM, sa*****@yahoo.co.in wrote:
On May 4, 10:59 am, aki <akhileshrawat...@gmail.comwrote:
>//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;

};

//in main file

authProt ap;

----
----
memberfun();

// In memberfunc()

ap.type=1; // there is segmentaion fault here i do not know why?

any comments please?
thanks
aki

you have just declared the object, have you allocated space for the
same with new operator?
Why should he?

If I say
ClassName foo;
then there's no need to 'new' anything.
Stefan
--
Stefan Naewe
stefan dot naewe at atlas-elektronik dot com
May 4 '07 #5
aki
On May 4, 11:38 am, sam_...@yahoo.co.in wrote:
On May 4, 10:59 am, aki <akhileshrawat...@gmail.comwrote:
//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;
};
//in main file
authProt ap;
----
----
memberfun();
// In memberfunc()
ap.type=1; // there is segmentaion fault here i do not know why?
any comments please?
thanks
aki

you have just declared the object, have you allocated space for the
same with new operator?
do i need separate memory allocation..
if i am right ... memory for object is created when its declared...

May 4 '07 #6
On May 4, 9:25 am, aki <akhileshrawat...@gmail.comwrote:
On May 4, 11:38 am, sam_...@yahoo.co.in wrote:
On May 4, 10:59 am, aki <akhileshrawat...@gmail.comwrote:
//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;
};
//in main file
authProt ap;
----
----
memberfun();
// In memberfunc()
ap.type=1; // there is segmentaion fault here i do not know why?
any comments please?
you have just declared the object, have you allocated space for the
same with new operator?
do i need separate memory allocation..
if i am right ... memory for object is created when its declared...
When it is defined, not just declared.

Regretfully, you don't provide enough context for me to really
say anything. If "authProt ap;" is in global scope, it is a
definition, and there shouldn't be any problem. You speak of
"memberfunc()", however: member of what? And where is ap
defined, and how is memberfunc called?

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

May 4 '07 #7
"aki" <ak**************@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;

};

//in main file

authProt ap;

----
----
memberfun();

// In memberfunc()

ap.type=1; // there is segmentaion fault here i do not know why?
any comments please?
Nothing per se wrong with that code, it should run fine. Which means your
problem is elsewhere and that's just where it's cropping up. It could be
buffer overflow somewhere or something else. The only way we could know is
if you could give us a small compilable program that gives a segmentation
fault with this problem.
May 5 '07 #8
On 5ÔÂ4ÈÕ, ÏÂÎç1ʱ59·Ö, aki <akhileshrawat...@gmail..comwrote:
//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;

};

//in main file

authProt ap;

----
----
memberfun();

// In memberfunc()

ap.type=1; // there is segmentaion fault here i do not know why?

any comments please?
thanks
aki
The code you posted should work OK. I think there must be other code
that damage the memory space of "ap". We need a small code which will
cause the fault so that we can give you more help.

May 6 '07 #9

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

Similar topics

0
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since...
4
by: Amadeus | last post by:
Hello Everybody! I have a problem with MySQL servers running RedHat 9 (smp kernel 2.4.20) on Intel and MySQL server 4.0.14 (problem also appears on binary distr 4.0.15 and on 4.0.15 I bilt myself...
32
by: John | last post by:
Hi all: When I run my code, I find that the memory that the code uses keeps increasing. I have a PC with 2G RAM running Debian linux. The code consumes 1.5G memory by the time it finishes...
17
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
16
by: JCauble | last post by:
We have a large Asp.net application that is currently crashing our production servers. What we are seeing is the aspnet_wp eat up a bunch of memory and then stop unexpectedly. Does not recycle. ...
7
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports...
9
by: Bruno Barberi Gnecco | last post by:
I'm using PHP to run a CLI application. It's a script run by cron that parses some HTML files (with DOM XML), and I ended up using PHP to integrate with the rest of the code that already runs the...
9
by: jeungster | last post by:
Hello, I'm trying to track down a memory issue with a C++ application that I'm working on: In a nutshell, the resident memory usage of my program continues to grow as the program runs. It...
17
by: frederic.pica | last post by:
Greets, I've some troubles getting my memory freed by python, how can I force it to release the memory ? I've tried del and gc.collect() with no success. Here is a code sample, parsing an XML...
27
by: George2 | last post by:
Hello everyone, Should I delete memory pointed by pointer a if there is bad_alloc when allocating memory in memory pointed by pointer b? I am not sure whether there will be memory leak if I do...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.