I’m porting a C++ sdk from Windows to Mac OSX 10.5. I have a problem in Xcode where my breakpoints in certain files will only be hit if I set them while debugging. If I stop debugging and then restart, the breakpoints no longer get hit. If I add them while not debugging, they don't get hit. This is only in certain files and my breakpoint...
I think i might need to use a boolean bValue = false for my while condition:
char cArray[ 100 ] = "";
ifstream object;
cout << "Enter full path name: ";
cin.getline( cArray, 100 );
if ( !object ) return -1 // Path is not valid? This statement executes why?
ifstream object.open( cArray, 100 );
// read the contents of a text file unti...
Hy all,
I believe that the following piece of code is generating memory leak?
/* External function to dynamically allocate a vector */
template <class T>
T *dvector(int n){
T *v;
v = (T *)malloc(n*sizeof(T));
return v;
}
/* Function that calls DVECTOR and, after comput...
Is there anyway I can incorporate a pretty large text file (about 700KBs) into the program itself, so I don't have to ship the text files together in the application directory ? This is the first time I'm trying to do something like this, and I have no idea where to start from.
Help is greatly appreciated (:
...
After posting my solution to my own problem regarding memory issues, nusi suggested that my solution lacks locking.
The following pseudo code vaguely represents my solution in a very simple way.
std::map<int, MyType1> myMap;
void firstFunctionRunFromThread1()
{
MyType1 mt1;
mt1.Test = "Test 1";
myMap[0] = mt1;
}
void only...
Pointer to members are not used very much but they are really powerful, how have you used them and what's the coolest things you've done?
Edit:
This is not so much to list things that are possible, for example listing boost::bind and boost::function aren't good. Instead maybe a cool usage with them? I know they're very cool in themselve...
This is my code... I don't know why I'm get an error segment... could somebody explain the reason to me?
#include <iostream>
#include <string>
// Required by for routine
#include <sys/types.h>
#include <unistd.h>
using namespace std;
int globalVariable = 2;
main()
{
string sIdentifier;
int iStackVariable = 20;
pid_t p...
Using MSXML via C++, when I call IXMLDOMDocument::save, empty XML elements will get an end tag, like this:
<root>
<child name="first">
</child>
</root>
But I want it saved as this:
<root>
<child name="first" />
</root>
What do I need to do to accomplish that?
...
Consider this code (using CString because it's familiar and easy to see when not constructed, but nothing special about the class), tested under Visual Studio 2008:
CString DoSomething( const CString& sString )
{
return sString;
}
CString sTest1 = DoSomething( sTest1 ); // Compiles (no warnings), fails at runtime
CString sTest2( Do...
I'm trying to get emacs to correctly format the "for each" construct in c++.
I want the braces to be lined up with the f in for in both of the following examples:
for each(Type a in b)
{ //^c^s shows substatement-open
//... do stuff
}
for( ; ; )
{ //^c^s shows substatement-open
//... do stuff
}
In b...
I have the following functor for redefining the less operator of the sort method for the vector type:
typedef vector< vector<int> > MxInt2d;
typedef vector< vector<double> > MxDouble2d;
class QSweep{
public:
....
static MxDouble2d myPoints_;
MxDouble2d myEdges_;
class order{
public:
bool operator() (const vector<int>& edge1, c...
I have to build a class polynom (polinom) inherited from class lista (list). I have to add , substract ,multiply , divide 2 objects from the polynom class.
I have this piece of code. I don't understand why my destructors aren't working. I also have to overload the operators: +,-,<<,>> but I don't know how to.
#include <iostream>
#inclu...
I'm having trouble iterating in reverse over a map in gcc c++. When I use a reverse iterator, it seems I can't assign anything to it - the compiler complains. I'm working around it with some awkward code using a forward iterator, but it's not very elegant. Any thoughts?
...
Updated: The actual resolution that the compile box which served my compile request was different. In the slower instance I was running code compiled on a SuSE 9 but running on a SuSE 10 box. That was sufficient difference for me to drop it and compare apples to apples. When using the same compile box the results were as follows:
g++...
I have an application that keeps using up more and more memory as time goes by (while actively running), but there are no leaks. So I know the program isn't doing something totally wrong, which would be easy to find.
Instead I want to track allocations so I can start tracking down the issue, and on a Mac I'd use Instruments, which gives...
I want to make my own malloc/free so I can make a precise copying allocator.
Any gurus have any tips and suggestions?
I have a few questions for now:
Should I just malloc large chunks of memory, and then distribute from that so I don't have to call the system calls?
How are copying collectors usually done? I would imagine that this p...
I have a ray, I need to find the closest line segment that it hits. I think it's possible to do this in O(log n) time if I sort the line segments first, but I can't remember how to sort them... I think some sort of tree would work best, but how do I sort them by both start and end point? I would also like fast insertions into this data s...
Hi guys,
Is there a way to access Borland output in VC++, for method calls and other stuff?
Thanks
...
Can anyone see what's wrong with this code?
SIZE_BG is 6MB as I am trying to draw a large bitmap image (3366x600). I use malloc to prevent my image from overflowing the stack. I get an access violation error on the call to glDrawPixels(). bgPtr seems to point to the correct data as I checked the first few bytes before calling glDrawPix...
Hi,
jstack is very helpful to me in checking stack traces of live running processes.
Is there any tool in C++ to do this task. I am working with Solaris/GCC compilers.
Actually GDB/DBX can do that. But my process is hanging some times that to very rarely. So when that is hanging I want to know where it is going wrong. Just track that ...