12-05-2008
I think the code looks okay (but I'm not a C++ expert). It could be that x and y no longer hold the original reference to your allocated arrays. In that case, the pointers might point somewhere they did not originally. Try this: after instantiating the m_Genes object, create a "shallow copy" of it, then before you distruct, compare the shallow copy with the m_Genes copy. If there's a difference in pointer values, that might be your problem.
Another possibility just occurred to me: It could be that you made a shallow copy of m_Genes and deleted the shallow copy as if it were a deep copy. That is, you already freed the pointers in m_Genes->x and ->y.
10 More Discussions You Might Find Interesting
1. Programming
hi,
I have made a small C program that make use of malloc and free for processing bitmap images. when i try to run the program, I am getting a error something like
*** glibc detected *** free(): invalid next size (normal): 0x0000000000503e70 ***
I am not sure of which free() is causing this... (1 Reply)
Discussion started by: vbreddy
1 Replies
2. Programming
when i try to use the class i wrote, i either get this:
*** glibc detected *** double free or corruption: 0x40236ff4 ***
and the proccess exits with an error code of 0;
or it segfaults. could someone look at my header file (with imp.) to give me some insight as to why its not working?
... (19 Replies)
Discussion started by: norsk hedensk
19 Replies
3. Homework & Coursework Questions
Hi All,
My latest assignment (practice not coursework!) is to write prototype interactive exam/test console application. I've used structs to store the question information (not sure if this was the best way to do it?) and I have the following code that outputs each question and it's possible... (0 Replies)
Discussion started by: pondlife
0 Replies
4. Homework & Coursework Questions
Hi, i'm trying to copy a struct into a binary file using the unix instruction write, so i declare and fill the struct "superbloque" in one function "initSB" and then i pass the pointer to another function called bwrite (for block write) which calls write. The problem is that i call the function... (2 Replies)
Discussion started by: ignatius3
2 Replies
5. Programming
In a well-known book on the C language, there is an example of an efficient method for using a struct member as an argument to a function. (I'm a C noob, but I believe the correct terminology might be: use call-by-reference instead of call-by-value.) The function is printf.
Anyway, here's a... (5 Replies)
Discussion started by: uiop44
5 Replies
6. Programming
Hi guys, I'm trying to understand pointers in C and made a simple example and I've problems with It.
Can someone help?
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int f1(char **str_);
int main(int argc, char **argv)
{
char *str = NULL;
f1(&str);
... (3 Replies)
Discussion started by: pharaoh
3 Replies
7. Programming
Hi Friends,
while executing the below code, am getting *** glibc detected *** ./ok: malloc(): memory corruption (fast) error, please suggest how to solve this issue.
#include <stdio.h>
#include <string.h>
#include <sqlca.h>
#include <alloca.h>
/* Define constants for VARCHAR... (2 Replies)
Discussion started by: mpjobsrch
2 Replies
8. Programming
I am facing a problem of memory corruption. The loop runs for the first time but does not go through the second time. What could be the problem?
for(int z=0;z<2;z++)
{
fp=fopen("poly.dat","r");
/*do something which reads this file into a 2D array*/
fclose(fp);
... (10 Replies)
Discussion started by: dare
10 Replies
9. Programming
Currently I test a shared library vendor provided in linux , the following is the simple source :
#include <iostream>
using namespace std;
extern int test1();
extern int test2();
int main()
{
cout << "hello world" << endl ;
return 0 ;
cout << "Test 1" << endl;
... (6 Replies)
Discussion started by: barfatchen
6 Replies
10. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I'm doing aproximation of derivative called five-point stencil. For every value of x, in interval , in step... (0 Replies)
Discussion started by: antonija
0 Replies
LEARN ABOUT CENTOS
qstrlist
QStrList(3qt) QStrList(3qt)
NAME
QStrList - Doubly-linked list of char*
SYNOPSIS
#include <qstrlist.h>
Inherits QPtrList<char>.
Inherited by QStrIList.
Public Members
QStrList ( bool deepCopies = TRUE )
QStrList ( const QStrList & list )
~QStrList ()
QStrList & operator= ( const QStrList & list )
DESCRIPTION
The QStrList class provides a doubly-linked list of char*.
If you want a string list of QStrings use QStringList.
This class is a QPtrList<char> instance (a list of char*).
QStrList can make deep or shallow copies of the strings that are inserted.
A deep copy means that memory is allocated for the string and then the string data is copied into that memory. A shallow copy is just a
copy of the pointer value and not of the string data itself.
The disadvantage of shallow copies is that because a pointer can be deleted only once, the program must put all strings in a central place
and know when it is safe to delete them (i.e. when the strings are no longer referenced by other parts of the program). This can make the
program more complex. The advantage of shallow copies is that they consume far less memory than deep copies. It is also much faster to copy
a pointer (typically 4 or 8 bytes) than to copy string data.
A QStrList that operates on deep copies will, by default, turn on auto-deletion (see setAutoDelete()). Thus, by default QStrList will
deallocate any string copies it allocates.
The virtual compareItems() function is reimplemented and does a case-sensitive string comparison. The inSort() function will insert strings
in sorted order. In general it is fastest to insert the strings as they come and sort() at the end; inSort() is useful when you just have
to add a few extra strings to an already sorted list.
The QStrListIterator class is an iterator for QStrList.
See also Collection Classes, Text Related Classes, and Non-GUI Classes.
MEMBER FUNCTION DOCUMENTATION
QStrList::QStrList ( bool deepCopies = TRUE )
Constructs an empty list of strings. Will make deep copies of all inserted strings if deepCopies is TRUE, or use shallow copies if
deepCopies is FALSE.
QStrList::QStrList ( const QStrList & list )
Constructs a copy of list.
If list has deep copies, this list will also get deep copies. Only the pointers are copied (shallow copy) if the other list does not use
deep copies.
QStrList::~QStrList ()
Destroys the list. All strings are removed.
QStrList & QStrList::operator= ( const QStrList & list )
Assigns list to this list and returns a reference to this list.
If list has deep copies, this list will also get deep copies. Only the pointers are copied (shallow copy) if the other list does not use
deep copies.
SEE ALSO
http://doc.trolltech.com/qstrlist.html http://www.trolltech.com/faq/tech.html
COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license
statement.
AUTHOR
Generated automatically from the source code.
BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you.
Thank you.
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a
web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially
supported by Trolltech.
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page
(qstrlist.3qt) and the Qt version (3.3.8).
Trolltech AS 2 February 2007 QStrList(3qt)