Click here to Skip to main content
15,887,485 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Button Size Pin
AbhiHcl19-May-10 21:35
AbhiHcl19-May-10 21:35 
AnswerRe: Button Size Pin
Aescleal19-May-10 22:57
Aescleal19-May-10 22:57 
QuestionAbout MSDN Library? Pin
Syouki_kou19-May-10 16:27
Syouki_kou19-May-10 16:27 
AnswerRe: About MSDN Library? Pin
Niklas L2-Jun-10 9:24
Niklas L2-Jun-10 9:24 
Questiondebugging app to find out which code module doesn't decrease a count Pin
abiemann19-May-10 10:43
abiemann19-May-10 10:43 
AnswerRe: debugging app to find out which code module doesn't decrease a count Pin
«_Superman_»19-May-10 10:53
professional«_Superman_»19-May-10 10:53 
AnswerRe: debugging app to find out which code module doesn't decrease a count Pin
abiemann19-May-10 11:06
abiemann19-May-10 11:06 
AnswerRe: debugging app to find out which code module doesn't decrease a count Pin
Luc Pattyn19-May-10 11:11
sitebuilderLuc Pattyn19-May-10 11:11 
First of all, if you are using multiple threads (explicit ones, or implicit ones such as used by asynchronous events, callback routines, etc), and your counter increment/decrement isn't atomic, it may well be that the number of calls is correct and the value is incorrect.

Assuming you have verified that, you will need to differentiate your function calls; an easy way would be to give them one positive integer parameter, using the same value for matching pairs of incCount(id) and decCount(id).

Then you want to count the operations for different id values in separate accumulators. There are many ways to do so:
- use an array, ranging from 0 to maximum(id);
- if that is not doable, use a smaller array with P elements, and use id%P
(the modulo operator will map any value of id to a valid index for your array).

Special case: if only one decCount() call is missing, you might even try this:

int count=0;
int P=32;

void incCount(int id) {
    count^=1<<(id%P);
}

void decCount(int id) {
    count^=1<<(id%P);
}

which means each call is toggling one bit in a single counter (assuming P is 32 or less); in the end the bit number of the one non-zero bit gives you the id%P. And you could use additional runs with different P values to find the actual value of id!

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read formatted code with indentation, so please use PRE tags for code snippets.

I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).

GeneralRe: debugging app to find out which code module doesn't decrease a count [modified] Pin
abiemann19-May-10 11:23
abiemann19-May-10 11:23 
GeneralRe: debugging app to find out which code module doesn't decrease a count Pin
Luc Pattyn19-May-10 11:31
sitebuilderLuc Pattyn19-May-10 11:31 
GeneralRe: debugging app to find out which code module doesn't decrease a count Pin
abiemann19-May-10 13:33
abiemann19-May-10 13:33 
AnswerRe: debugging app to find out which code module doesn't decrease a count Pin
Aescleal19-May-10 12:31
Aescleal19-May-10 12:31 
AnswerRe: debugging app to find out which code module doesn't decrease a count Pin
Roger Allen21-May-10 6:30
Roger Allen21-May-10 6:30 
GeneralRe: debugging app to find out which code module doesn't decrease a count Pin
abiemann21-May-10 8:52
abiemann21-May-10 8:52 
Questionhow to stop run of a program after a message display [modified] Pin
mrby12319-May-10 7:10
mrby12319-May-10 7:10 
QuestionRe: how to stop run of a program after a message display Pin
David Crow19-May-10 7:32
David Crow19-May-10 7:32 
AnswerRe: how to stop run of a program after a message display Pin
mrby12319-May-10 8:23
mrby12319-May-10 8:23 
QuestionRe: how to stop run of a program after a message display Pin
David Crow19-May-10 8:44
David Crow19-May-10 8:44 
AnswerRe: how to stop run of a program after a message display Pin
Luc Pattyn19-May-10 7:39
sitebuilderLuc Pattyn19-May-10 7:39 
GeneralRe: how to stop run of a program after a message display Pin
mrby12319-May-10 9:13
mrby12319-May-10 9:13 
GeneralRe: how to stop run of a program after a message display Pin
Luc Pattyn19-May-10 9:39
sitebuilderLuc Pattyn19-May-10 9:39 
GeneralRe: how to stop run of a program after a message display Pin
mrby12319-May-10 10:40
mrby12319-May-10 10:40 
GeneralRe: how to stop run of a program after a message display Pin
«_Superman_»19-May-10 10:46
professional«_Superman_»19-May-10 10:46 
GeneralRe: how to stop run of a program after a message display Pin
Luc Pattyn19-May-10 11:19
sitebuilderLuc Pattyn19-May-10 11:19 
GeneralRe: how to stop run of a program after a message display Pin
mrby12319-May-10 12:12
mrby12319-May-10 12:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.