473,399 Members | 3,106 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.

RWTPtrSlist core dumps, while removing entries.

#include <rw/tpslist.h>
#include <iostream>
using namespace std;

int main(){
RWTPtrSlist<int> dates;
dates.insert(new int(2)); // 6/2/52
dates.insert(new int(2)); // 6/2/52
// Remove in reverse order:
try
{
while (dates.get()); // When no more entries are there in
list.. it crashes..
}
catch(...)
{
cout << "here" <<endl;
}
return 0;

Jun 13 '06 #1
2 3043
Neha wrote:
#include <rw/tpslist.h>
#include <iostream>
using namespace std;

int main(){
RWTPtrSlist<int> dates;
dates.insert(new int(2)); // 6/2/52
dates.insert(new int(2)); // 6/2/52
// Remove in reverse order:
try
{
while (dates.get()); // When no more entries are there in
list.. it crashes..
}
catch(...)
{
cout << "here" <<endl;
}
return 0;


We don't know anything about RWTPtrSlist<> since it is not a standard
class. If you wrote it, show us that class and its implementation, or
if you didn't, ask the vendor of the library.

Cheers! --M

Jun 13 '06 #2
On 12 Jun 2006 20:14:25 -0700, "Neha" <ne********@gmail.com> wrote:
#include <rw/tpslist.h>
#include <iostream>
using namespace std;

int main(){
RWTPtrSlist<int> dates;
dates.insert(new int(2)); // 6/2/52
dates.insert(new int(2)); // 6/2/52
// Remove in reverse order:
try
{
while (dates.get()); // When no more entries are there in
list.. it crashes..


The Rogue Wave library is off topic but the general approach how to
tackle such a problem is probably on topic:

1. Read the manual:
http://www.roguewave.com/support/doc...t.html#idx3150

The function get() "Removes and returns the first element in the
collection". The description does not tell you that it checks for an
empty list and that it returns NULL in case of an empty list. So
probably you have to do that. Also your comment ("// Remove in reverse
order") is probably wrong.

2. Write a short unit test to verify your assumption:

RWTPtrSlist<int> dates;
dates.insert(new int(2));
dates.insert(new int(2));

int i = 0;

while (!dates.isEmpty()) {
int* p = dates.removeLast();
++i;
delete p;
}
assert (i == 2);
assert (dates.isEmpty());
BTW, both your pogram and Rogue Waves example contain memory leaks.

Best wishes,
Roland Pibinger
Jun 13 '06 #3

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

Similar topics

3
by: Nick Craig-Wood | last post by:
I've just discovered that my python (Python 2.3.4 from debian package 2.3.4-1 running on debian testing x86 + linux 2.4.26) core dumps when I set recursionlimit very high and do lots of recursion....
5
by: Ganesh Gella | last post by:
Hi All, I am using g++ on Linux, and my code has lot of vectors each stores a particualr type of structure. (Structure internally had some vectors). When I am trying to push_back an element to...
9
by: Lil | last post by:
Hi Everyone! I've been trying to figure out this weird bug in my program. I have a python program that calls a C function that reads in a binary file into a buffer. In the C program, buffer is...
4
by: oshinonline | last post by:
Hi, In my application I have RWTPtrSlist<POSIXThread>, where POSIXThread is my wrapper class. Whenever I create a new thread I call append on the list. But it hangs after I created 11/12...
2
by: Neha | last post by:
#include <rw/tpslist.h> #include <iostream> using namespace std; int main(){ RWTPtrSlist<int> dates; dates.insert(new int(2)); // 6/2/52 dates.insert(new int(2)); // 6/2/52 //...
7
by: v4vijayakumar | last post by:
why the following code dumps core? TIA. #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *agrv) { int i = 0; typedef char ca_t;
1
by: simon | last post by:
I am having problem with an application which core dumps while deleting a vector here is the snippet : Event_Node_t struct defined in the header : +++++++++++++++++++++++++++++++++++++...
8
by: J. D. Leach | last post by:
I am not sure whether this would be considered off topic or not, but here goes.....don't flame me too bad. Running GNU GCC 4.0.1 and GDB 6.3. Was checking my compiler and debugger output prior...
2
by: Bruno Gonzalez (STenyaK) | last post by:
(first of all, sorry if this is not the correct place to ask, but i couldn't find a better one...) I'm new to debugging using core dumps. I've managed to get core dumps + symbols using g++ and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.