I have inherited a very long set of macros from some C algorithm code.They basically call free on a number of structures as the function exits either abnormally or normally. I would like to replace these with something more debuggable and readable. A snippet is shown below
#define FREE_ALL_VECS {FREE_VEC_COND(kernel);FREE_VEC_COND(cirra...
what is the difference between deleting a pointer, setting it to null, and freeing it.
delete ptr;
vs.
ptr=NULL;
vs.
free(ptr);
...
I am using the following code for reading lines from a text-file. What is the best method for handling the case where the line is greater than the limit SIZE_MAX_LINE?
void TextFileReader::read(string inFilename)
{
ifstream xInFile(inFilename.c_str());
if(!xInFile){
return;
}
char acLine[SIZE_MAX_LINE + 1];
...
Why the following code works?
typedef char (&yes)[1];
typedef char (&no)[2];
template <typename B, typename D>
struct Host
{
operator B*() const;
operator D*();
};
template <typename B, typename D>
struct is_base_of
{
template <typename T>
static yes check(D*, T);
static no check(B*, int);
static const bool value = sizeo...
Hello.
I'm fixing some bugs in the application for remote control (remote desktop-like) for Windows.
And there is a feature that you can blank screen on remote machine - all the programms keep running unaffected, but the person who looks into the display on remote PC sees nothing but black screen.
It is implemented by sending IoCtl requ...
I want objects managed by a shared_ptr to be allocated from a pool, say Boost's Pool interface, how can this be achieved?
...
Being fairly new to C++ I have a question bascially concerning the g++ compiler and especially the inclusion of libraries. Consider the following makefile:
CPPFLAGS= -I libraries/boost_1_43_0-bin/include/ -I libraries/jpeg-8b-bin/include/
LDLIBS= libraries/jpeg-8b-bin/lib/libjpeg.a
# LDLIBS= -L libraries/jpeg-8b-bin/lib -llibjpeg
all: ...
Hello everyone,
If the title was not clear, I will try to clarify what I am asking:
Imagine I have a variable called counter, I know I can see its current value by doing something like:
std::cout << counter << std::endl;
However, assume I have lots of variables and I don't know which I'm going to want to look at until runtime.
Doe...
Hi,
i need to help with structures, inheritance and definition.
//define struct
struct tStruct1{
int a;
};
//definition
tStruct1 struct1{1};
and inheritance
struct tStruct2:tStruct1{
int b;
};
How can I define it in declaration line?
tStruct2 struct2{ ????? };
One more question, how can i use inheritance for structures ...
I have a container class (containing a multi-index container) for which I have a public "foreach" member-function, so users can pass a functor to apply on all elements.
While implementing, I had a case where the functor should only be applied to some elements of a range in the container, so I overloaded the foreach, to pass some valid ra...
Trying to put up a "Do you want to save"-dialog when trying to close window with close-button in taskbar thumbnail in windows 7(with aero peek active).
Using MessageBox() when processing WM_CLOSE does not work. MessageBox won't show until you move mouse cursor outside thumbnail so aero peek is disabled.
Lots of applications have this b...
Hey I was writing a udp client server in which a client waits for packets from server.But I want to limit this wait for certain time.After client don't get response for a certain moment in raise an alarm,basically it comes out and start taking remedy steps.So what are the possible solution for it.I think writing a wrapper around recv wil...
I have a method as follows (from a class than implements TBB task interface - not currently multithreading though)
My problem is that two ways of accessing a vector are causing quite different behaviour - one works and the other causes the entire program to bomb out quite spectacularly (this is a plugin and normally a crash will be caugh...
Hello
I'm developing a DirectShow filter which has 2 input pins (1 for audio, 1 for video). I'm using libavcodec/libavformat/libavutil of FFMpeg for encoding the video to H264, audio to AAC and mux it/stream using RTP. So far I was able to encode video and audio correctly using libavcodec but now I see that FFMpeg seems to support RTP mu...
I'm doing a library that makes extensive use of a thread local variable.
Can you point to some benchmarks that test the performances of the different ways to get thread local variables in C++:
C++0x thread_local variables
compiler extension (Gcc __thread, ...)
boost::threads_specific_ptr
pthread
Windows
...
Does C++0x thread_local ...
I'm trying to calcuate size of each cell (containing text like "ff" or "a0"), so that 32 cells will fit into window by width.
However, charWidth*2 doesn' represent the width of a cell, since it doesn't take spacing between characters in the account.
How can I obtain size of a font so that 32 cells each is two chars like "ff" fit exactly...
We're upgrading from VS2005 to VS2010.
We are almost there but there is a problem with Crystal Reports.
We use the RDC (COM-based) component within our C++ application.
On Windows 7 or on VISTA, I can't get the viewer nor the designer controls working.
I get Access Violations when the control is activated:
// from atlhost.h (line 2208)...
Hi guys, i'm developing an array structure just for fun.
This structure, generalized by a template parameter, pre allocates a given number of items at startup, then, if "busy" items are more than available ones, a function will realloc the inner buffer .
The testing code is :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
t...
I'm looking for a fast, lightweight open-source HTML parser -- something along the lines of a non-validating SAX parser (except, of course, for HTML).
The answers to this question cover a parser that generates a DOM (don't want that), and these answers suggest conforming the HTML to XML before sending it to Xerxes (can't do that in my c...
I was trying to understand how webkit parses urls, and I'm having a hard time making heads or tails of this:
Vector<char, 4096> buffer(fragmentEnd * 3 + 1);
This line is on line 1214 (you can see it here: http://trac.webkit.org/browser/trunk/WebCore/platform/KURL.cpp#L1214). I get that it's making a vector of type char, with each ent...