473,387 Members | 1,497 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.

std::vector destructor ?

eb
I have in a header file

Class MyClasse : public Foo
{
....
std::vector <int> v;
}

Nothing in the code for initialization
(and even if there is something, the error remains).

When the program quits, I get the error :

*** glibc detected *** free(): invalid pointer: 0x083e8930 ***

I think this might be cause by the program wanting to free some already
freed memory
This dissapears if I comment out the incrimnated line ...

Any idea ?
Jun 14 '06 #1
3 4489
eb wrote:
I have in a header file

Class MyClasse : public Foo "Class" is not a keyword. Use "class". {
... .... is not valid here. std::vector <int> v;
} Missing semicolon.
Nothing in the code for initialization
(and even if there is something, the error remains).

When the program quits, I get the error :

*** glibc detected *** free(): invalid pointer: 0x083e8930 ***

I think this might be cause by the program wanting to free some already
freed memory
This dissapears if I comment out the incrimnated line ...
Which line would that be? On which line does your debugger tell you the
problem is happening?

Any idea ?


You need to post enough code for us to actually see the problem.
Jun 14 '06 #2
Alan Johnson wrote:
eb wrote:
I have in a header file

Class MyClasse : public Foo

"Class" is not a keyword. Use "class".
{
...

... is not valid here.
std::vector <int> v;
}

Missing semicolon.

Nothing in the code for initialization
(and even if there is something, the error remains).

When the program quits, I get the error :

*** glibc detected *** free(): invalid pointer: 0x083e8930 ***

I think this might be cause by the program wanting to free some already
freed memory
This dissapears if I comment out the incrimnated line ...


Which line would that be? On which line does your debugger tell you the
problem is happening?

Any idea ?


You need to post enough code for us to actually see the problem.


(to the OP) And it should be the code you actually tried, not some pseudo
code that contains a lot of other errors.

Jun 14 '06 #3
eb
Rolf Magnus wrote:
Alan Johnson wrote:
eb wrote:
I have in a header file

Class MyClasse : public Foo

"Class" is not a keyword. Use "class".
{
...

... is not valid here.
std::vector <int> v;
}

Missing semicolon.

Nothing in the code for initialization
(and even if there is something, the error remains).

When the program quits, I get the error :

*** glibc detected *** free(): invalid pointer: 0x083e8930 ***

I think this might be cause by the program wanting to free some already
freed memory
This dissapears if I comment out the incrimnated line ...


Which line would that be? On which line does your debugger tell you the
problem is happening?

Any idea ?


You need to post enough code for us to actually see the problem.


(to the OP) And it should be the code you actually tried, not some pseudo
code that contains a lot of other errors.


If only it would raise helpful answers, I'm more than happy to post the real
code. The incriminated line is pointed with an arrow.

This code is from qGo open source project at qgo.sourceforge.net

Please be so kind as to provide *question related* comments in this thread.

I'm more than happy to discuss other code correctness issues in an other
thread.

/*
* board.h
*/

#ifndef BOARD_H
#define BOARD_H

#include "defines.h"
#include "setting.h"
#include "boardhandler.h"
#include "stone.h"
#include "move.h"
#include <qcanvas.h>
#include <qdatetime.h>
#include <qpainter.h>
#include <vector>

class ImageHandler;
class Mark;
class Tip;
class InterfaceHandler;
class GameData;
class NodeResults;
class QNewGameDlg;

class Board : public QCanvasView
{
Q_OBJECT

public:
Board(QWidget *parent=0, const char *name=0, QCanvas* c=0);
~Board();
void clearData();
void initGame(GameData *d, bool sgf=false);
void setModified(bool m=true);
void updateCaption();
ImageHandler* getImageHandler() { return imageHandler; }
BoardHandler* getBoardHandler() { return boardHandler; }
InterfaceHandler* getInterfaceHandler();
Stone* addStoneSprite(StoneColor c, int x, int y, bool &shown);
void updateCanvas() { canvas->update(); }
void increaseSize();
void decreaseSize();
QString getCandidateFileName();
void hideAllStones();
void hideAllMarks();
bool openSGF(const QString &fileName, const QString &filter=0);
bool saveBoard(const QString &fileName) { return
boardHandler->saveBoard(fileName); }
void setShowCoords(bool b);
void setShowSGFCoords(bool b);
void setShowCursor(bool b);
void setVariationDisplay(VariationDisplay d);
void setMode(GameMode mode) { boardHandler->setMode(mode); }
void addStone(StoneColor sc, int x, int y, bool sound = 0) {
boardHandler->addStone(sc, x, y, sound); }
void setHandicap(int h) { boardHandler->setHandicap(h); }
GameMode getGameMode() { return boardHandler->getGameMode(); }
void setMarkType(MarkType t) { boardHandler->setMarkType(t); }
MarkType getMarkType() const { return boardHandler->getMarkType(); }
void setMark(int x, int y, MarkType t, bool update=true, QString txt=0,
bool overlay=true);
void removeMark(int x, int y, bool update=true);
void setMarkText(int x, int y, const QString &txt);
Mark* hasMark(int x, int y);
void updateLastMove(StoneColor c, int x, int y);
void setCurStoneColor();
void removeLastMoveMark();
void checkLastMoveMark(int x, int y);
bool nextMove(bool autoplay=false) { return
boardHandler->nextMove(autoplay); }
void previousMove() { boardHandler->previousMove(); }
void nextVariation() { boardHandler->nextVariation(); }
void previousVariation() { boardHandler->previousVariation(); }
void nextComment() { boardHandler->nextComment(); }
void previousComment() { boardHandler->previousComment(); }
void gotoFirstMove() { boardHandler->gotoFirstMove(); }
void gotoLastMove() { boardHandler->gotoLastMove(); }
void gotoLastMoveByTime() { boardHandler->gotoLastMoveByTime(); }
void gotoMainBranch() { boardHandler->gotoMainBranch(); }
void gotoVarStart() { boardHandler->gotoVarStart(); }
void gotoNextBranch() { boardHandler->gotoNextBranch(); }
void gotoNthMove(int n) { boardHandler->gotoNthMove(n); }
void gotoNthMoveInVar(int n) { boardHandler->gotoNthMoveInVar(n); }
void navIntersection();
void cutNode() { boardHandler->cutNode(); }
void pasteNode(bool brother=false) { boardHandler->pasteNode(brother); }
void deleteNode() { boardHandler->deleteNode(); }
void clearNode() { boardHandler->clearNode(); }
void duplicateNode() { boardHandler->duplicateNode(); }
bool swapVariations() { return boardHandler->swapVariations(); }
void doPass();
void doSinglePass() { boardHandler->doPass(); }
void doAdjourn() { emit signal_adjourn(); }
void doUndo() { emit signal_undo(); }
void doResign();// { emit signal_resign(); }
void doRefresh() { emit signal_refresh(); }
void doEditBoardInNewWindow() { emit signal_editBoardInNewWindow(); }
void setVarGhost(StoneColor c, int x, int y);
bool hasVarGhost(StoneColor c, int x, int y);
void removeGhosts();
short getCurrentX() const { return curX; }
short getCurrentY() const { return curY; }
int getCurrentMoveNumber() const;
GameData* getGameData() { return boardHandler->getGameData(); }
void setGameData(GameData *gd) { boardHandler->setGameData(gd); }
void exportPicture(const QString &fileName, const QString &filter, bool
toClipboard=false);
void exportASCII() { boardHandler->exportASCII(); }
bool importASCII(const QString &fileName, bool fromClipboard=false)
{ return boardHandler->importASCII(fileName, fromClipboard); }
bool importSGFClipboard() { return boardHandler->importSGFClipboard(); }
bool exportSGFtoClipB() { return boardHandler->exportSGFtoClipB(); }
void countScore();
void doCountDone();
void numberMoves() { boardHandler->numberMoves(); }
void markVariations(bool sons) { boardHandler->markVariations(sons); }
void setBoardSize(int s) { board_size = s; }
int getBoardSize() const { return board_size; }
#ifndef NO_DEBUG
void debug();
#endif

bool fastLoad, isModified, lockResize;
void sendcomment(const QString &text) { emit signal_sendcomment(text); }

// in case of match
void set_myColorIsBlack(bool b) { myColorIsBlack = b; }
bool get_myColorIsBlack() { return myColorIsBlack; }
void set_isLocalGame(bool isLocal);
bool get_isLocalGame() { return isLocalGame; }
void refreshDisplay() { Move *m = boardHandler->getTree()->getCurrent();
updateLastMove(m->getColor(), m->getX(), m->getY()); }
bool startComputerPlay(QNewGameDlg *dlg,const QString &fileName, const
QString &filter, const QString &computer_path);
void set_antiClicko(bool b) { antiClicko = b; }

std::vector <int > v; // <------ There

public slots:
void updateComment();
void updateComment2();
void modifiedComment();
void changeSize();
void gotoMove(Move *m) { boardHandler->gotoMove(m); }

signals:
void coordsChanged(int, int, int,bool);
void signal_sendcomment(const QString&);
void signal_addStone(enum StoneColor, int, int);
void signal_Stone_Computer(enum StoneColor, int, int);
void signal_undo();
void signal_adjourn();
void signal_resign();
void signal_pass();
void signal_done();
void signal_refresh();
void signal_editBoardInNewWindow();

protected:
void calculateSize();
void drawBackground();
void drawGatter();
void drawGatter2();
void initGatter();
void drawCoordinates();
void drawStarPoint(int x, int y);
void resizeBoard(int w, int h);
int convertCoordsToPoint(int c, int o);
void contentsMousePressEvent(QMouseEvent *e);
void contentsMouseReleaseEvent(QMouseEvent*);
void contentsMouseMoveEvent(QMouseEvent *e);
void contentsWheelEvent(QWheelEvent *e);
void leaveEvent(QEvent*);
void resizeEvent(QResizeEvent*);
void updateMarkColor(StoneColor c, int x, int y);
private:
QCanvas *canvas;
ImageHandler *imageHandler;
BoardHandler *boardHandler;
int board_size, offset, offsetX, offsetY, square_size, board_pixel_size;
bool showCoords;
bool showSGFCoords;
bool showCursor;
bool antiClicko;
QList<Mark> *marks;
QList<Stone> *ghosts;
Mark *lastMoveMark;
bool numberPool[400];
bool letterPool[52];
Stone *curStone;
short curX, curY;
QTime wheelTime;
ButtonState mouseState;
NodeResults *nodeResultsDlg;

#ifdef Q_WS_WIN
bool resizeDelayFlag;
#endif

// in case of match
bool myColorIsBlack;
bool isLocalGame;
bool navIntersectionStatus;
};

#endif

Jun 14 '06 #4

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

Similar topics

26
by: BCC | last post by:
Hi, A colleague has some code like this: class CMyObject { // Bunch of Member functions } class CMyObjectList: public std::vector<CMyObject> {
27
by: Jason Heyes | last post by:
To my understanding, std::vector does not use reference counting to avoid the overhead of copying and initialisation. Where can I get a reference counted implementation of std::vector? Thanks.
0
by: Jason Heyes | last post by:
I wrote a previous post that asked whether there was a reference-counted implementation of std::vector. Apparantly there wasn't. So my next question is, is it possible to write your own shared...
5
by: Ernst Murnleitner | last post by:
Hello, is it possible to derive from std::vector and derive also its iterator? If I do it like in the example below, I get a problem when I need the begin of the vector: begin() returns the...
5
by: canned.net | last post by:
I have a class Scene that has several subclasses: World, Vault, etc. I fill a vector with these classes and then cannot go through and delete them. What's the trick to deleting pointers from a...
17
by: Michael Hopkins | last post by:
Hi all I want to create a std::vector that goes from 1 to n instead of 0 to n-1. The only change this will have is in loops and when the vector returns positions of elements etc. I am calling...
9
by: kathy | last post by:
I am using std::vector in my program: func() { std::vector <CMyClass *> vpMyClass; vpMyClass.push_back(new CMyClass()); vpMyClass.push_back(new CMyClass()); vpMyClass.push_back(new...
6
by: lokchan | last post by:
i want to create a vector of pointer s.t. it can handle new and delete but also have std::vector interface can i implement by partial specialization and inherence like follow ? #include...
7
by: Thomas | last post by:
I am compiling with g++ the fol. class: template<typename E> class C_vector_ : public std::vector<E> { private:
19
by: Daniel Pitts | last post by:
I have std::vector<Base *bases; I'd like to do something like: std::for_each(bases.begin(), bases.end(), operator delete); Is it possible without writing an adapter? Is there a better way? Is...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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:
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,...

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.