In unmanaged C/C++ code, what are the best practices to detect memory leaks? And coding guidelines to avoid? (As if it's that simple ;)
We have used a bit of a silly way in the past: having a counter increment for every memory allocation call and decrement while freeing. At the end of the program, the counter value should be zero.
I kn...
I wrote an Active X plugin for IE7 which implements IObjectWithSite besides some other necessary interfaces (note no IOleClient). This interface is queried and called by IE7. During the SetSite() call I retrieve a pointer to IE7's site interface which I can use to retrieve the IHTMLDocument2 interface using the following approach:
IUnkn...
I am writing a c program in linux. Commands like execv() require a path in the form of a c string. Is there a command that will return the current path in the form of a c style string?
...
How many rows should be in the (main) buffer of a virtual Listview control?
I am witting an application in pure 'c' to the Win32 API. There is an ODBC connection to a database which will retrieve the items (actually rows).
The MSDN sample code implies a fixed size buffer of 30 for the end cache (Which would almost certainly not be o...
The TEA is a very simple encryption algorithm requiring little time and space - perfect for embedded systems. There are extensions to it, and every version has its flaws (WEP was based on it), but for casual protection it's perfect.
In the vein of this topic on code review, I'm posting my code for critique. Interestingly, when I decid...
I'm used to doing all my coding in one C file. However, I'm working on a project large enough that it becomes impractical to do so. I've been #including them together but I've run into cases where I'm #including some files multiple times, etc. I've heard of .h files, but I'm not sure what their function is (or why having 2 files is bette...
How to set, clear and toggle a bit in C?
...
Can someone explain the mechanics of a jump table and why is would be needed in embedded systems?
...
I read somewhere once that the modulus operator is inefficient on small embedded devices such as 8 bit micros without integer division operator. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation.
Is there another way to do this other than keeping a counter variable ...
My build (gcc) toolchain produces a .map file. Is there a tool to analyze the memory map graphically?
...
I am a bit confused about socket programming in C.
You create a socket, bind it to an interface and an IP address and get it to listen. I found a couple of web resources on that, and understood it fine. In particular, I found an article Network programming under Unix systems to be very informative.
What confuses me is the timing of dat...
Why does n not equal 8 in the following function?
void foo(char cvalue[8]) {
int n = sizeof cvalue;
}
But n does equal 8 in this version of the function:
void bar() {
char cvalue[8];
int n = sizeof cvalue;
}
...
The first language i learnt was PHP, but i have more recently picked up python. As these are all 'high-level' languages, i have found them a bit difficult to pick up. I tried a bit of objective-c, and i just gave up.
So, what language should i learn to bridge between python to C
...
Following this question:
Good crash reporting library in c#
Is there any library like CrashRpt.dll that does the same on Linux? That is, generate a failure report including a core dump and any necessary environment and notify the developer about it?
Edit: This seems to be a duplicate of this question
...
When working on large code base with large team, its real challenge to maintain code quality and coding style.
well, controlling code quality is a huge topic on its own. But control of code style could be simplified with a tool.
We started using indent. Its real neat tool with huge set of options to configure. In the beginning we were ...
What is the difference between
Str[32] = "\0";
and
Str[32] = "";
...
I need to find out time taken by a function in my application. Application is a MS VIsual Studio 2005 solution, all C code.
I used thw windows API GetLocalTime(SYSTEMTIME *) to get the current system time before and after the function call which I want to measure time of.
But this has shortcoming that it lowest resolution is only 1msec...
On my OS X box, the kernel is a 32 bit binary and yet it can run a 64 bit binary.
How does this work?
cristi:~ diciu$ file ./a.out
./a.out: Mach-O 64-bit executable x86_64
cristi:~ diciu$ file /mach_kernel
/mach_kernel: Mach-O universal binary with 2 architectures
/mach_kernel (for architecture i386): Mach-O executable i386
/mach_ker...
Can anyone recommend a decent C image library?
I'm after loaders for bmp, gif, jpg, png and tga.
I want to use this for programming my Sony Playstation Portable, so opensource would be very handy.
After some googleing I've found FreeImage and CImg, but both feel rather heavy, and CImg is C++ not C.
Cheers
thing2k
...
Lets take the code
int a, b, c;
...
if ((a + b) > C)
If the values of a and b add to exceed the max value of an int will the integrity of the comparison be compromised? I was thinking that there might be an implicit up cast or overflow bit checked and factored into the evaluation of this expression.
...