473,320 Members | 1,865 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,320 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 3038
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.