c++

How could pairing new[] with delete possibly lead to memory leak only?

First of all, using delete for anything allocated with new[] is undefined behaviour according to C++ standard. In Visual C++ 7 such pairing can lead to one of the two consequences. If the type new[]'ed has trivial constructor and destructor VC++ simply uses new instead of new[] and using delete for that block works fine - new just call...

Behavior of WS_CLIPCHILDREN and InvalidateRect in Windows 7

To reduce flickering I create my parent windows using the WS_CLIPCHILDREN flag and I call InvalidateRect during the WM_SIZE event. This approach has worked well in Windows XP. However, I recently started programming on Windows 7 and I'm now experiencing rendering issues when resizing windows. When resizing a window its contents is not re...

'find' optimization

'find ./ -name *.jpg' I am trying to optimize 'find' command for the above statement. method which handle the '-name' predicate in find implementation. static boolean pred__name __common (const char *pathname, const char *str, int flags) { boolean b; char *base = base_name (pathname); strip__trailing __slashes(base); ...

Windows.h error

I am getting error : WINDOWS.H already included. MFC apps must not #include <windows.h> Help needed. ...

Optimizing regression testing in a C++ environnement

In order to avoid too much testing, I would like to provide the Quality Assurance (QA) team with hints on which features have to be regression tested after a development iteration. Do you know tools that could do that on a C++ and Subversion (and visual studio) dev environment ? Details about the use case: Features would be defined by...

How to save pointer to member in compile time?

Consider the following code template<typename T, int N> struct A { typedef T value_type; // OK. save T to value_type static const int size = N; // OK. save N to size }; Look, it is possible to save any template parameter if this parameter is a typename or an integer value. The thing is that pointer to member is an offset, i.e. int...

Program a system with C++

Hello everybody.. My question is simple because I am a beginner, so Can I program a full computer system with only using C++ language? Thanks. ...

What's the fastest way to deserialize a tree in C++

I'm working with a not so small tree structure (it's a Burkhard-Keller-Tree, > 100 MB in memory) implemented in C++. The pointers to the children of each node are stored in a QHash. Each node x has n children y[1] ... y[n], the edges to the children are labeled with the edit distance d(x, y[i]), so using a hash to store the nodes is an...

Exported function names does not contain argument list

I'm creating a plugin DLL using c++ in Eclipse. When trying to load the plugin I get an error: ?CTC_Cleanup@YAXXZ not found. Function is not available in myplugin.dll When comparing another working plugin with my plugin using Dependency Walker I notice that the function name in the other plugin is: "void CTC_Cleanup(void)", enabling ...

struct sizeof result not expected

Hey, I have a a struct defined thusly: typedef struct _CONFIGURATION_DATA { BYTE configurationIndicator; ULONG32 baudRate; BYTE stopBits; BYTE parity; BYTE wordLength; BYTE flowControl; BYTE padding; } CONFIGURATION_DATA; Now, by my reckoning, that struct is 10 bytes long. However, sizeof reports that it ...

Why [] is used in delete ( delete [] ) to free dynamically allocated array ?

I know that when delete [] will cause destruction for all array elements and then releases the memory. I initially thought that compiler wants it just to call destructor for all elements in the array ,but i have also a counter - argument for that which is: Heap memory allocator must know the size of bytes allocated and using sizeof(Ty...

Implementing 1 to n mapping for ORM c++

I am writing a project where I need to implement a stripped down version of an ORM solution in C++. I am struck in implementing 1-n relationships for the same. For instance, if the following are the classes: class A { ... } class B { ... std::list<A> _a_list; ... } I have provided load/save methods for loading/saving...

How can I make QtCreator compile with gsl library?

Hi, I am trying to use the GNU Scientific Library (GSL) http://www.gnu.org/software/gsl/ in QtCreator. How can I tell Qt creator to add these flags: http://www.gnu.org/software/gsl/manual/html%5Fnode/Linking-programs-with-the-library.html to link correctly? ...

Is there pointer to member traits or something like this?

Based on other my question. Consider the following code template<typename T, int N> struct A { typedef T value_type; // save T to value_type static const int size = N; // save N to size }; Look, I can use value_type and size as template parameter. typedef A<int, 2> A1; typedef A<A1::value_type, A1::size + 3> A2; // OK, A2 is A...

OpenCV cvNamedWindow not appearing under Fedora

Hello, As the title suggests I'm simply trying to get a named window to come up. I've been working with OpenCV for over a year now, and never had this problem before. For some reason, the window never opens. I've tried running some of my old scripts and everything works fine. As a very cut down example, see below #include "cv.h" #incl...

Is there any generic vesion of HashTable?

I need a class that will work like C++ std::map. More specifically, I need such a behavior: map< string, vector<int> > my_map; Is it possible? ...

bring malloc() back to its initial state

Do you know if there is a way to bring back malloc in its initial state, as if the program was just starting ? reason : I am developing an embedded application with the nintendods devkitpro and I would like to be able to improve debugging support in case of software faults. I can already catch most errors and e.g. return to the console ...

mysql aggregate UDF (user defined function) in C

I need to write an aggregate extension function (implemented in C) for mySQL 5.x. I have scoured the documentation (including browsing sql/udf_example.c) but I do not find anything that is brief, to the point and shows me just what I need to do. This is the problem: I have a C struct (Foo) I have a C function that takes an array of t...

Determine an included header files contribution to total file size

Hello, I am interested in reducing the file size of my application. It is a MFC/C++ application built with MVC++ in Visual Studio 2008. UPX does a good job of reducing the final exe to about 40% of its original size but I would like to reduce it more. MFC must be statically linked in this project. I have tried some methods outlined in ...

Crashing with gdiplus(new Bitmap)

My application is crashing on Bitmap* image = new Bitmap(hicon) in a old Win XP installation. The stack trace is showing it is in gdiplus.dll, the version of the dll in this system is 5.1.3097.0. I tried with a newer version of dll (5.1.6001.0) and it was working fine. Is this a bug with GDI Plus? or am I doing something wrong. What is ...