Showing tag results for Code

Sep 28, 2006
Post comments count0
Post likes count0

When you crash, make sure you crash in the right place

Raymond Chen
Raymond Chen

Last time, I recommended that functions should just crash when given invalid pointers. There's a subtlety to this advice, however, and that's making sure you crash in the right place. If your function and your function's caller both reside on the same side of a security boundary, then go ahead and crash inside your function. If the caller is a bad...

Code
Sep 26, 2006
Post comments count0
Post likes count0

Isn't DDE all asynchronous anyway?

Raymond Chen
Raymond Chen

"Isn't DDE all asynchronous anyway?" asks commenter KaiArnold. It's mostly asynchronous, but not entirely. You can read about how DDE works in MSDN, but since it seems people are reluctant to read the formal documentation, I'll repeat here the points relevant to the discussion. The DDE process begins with a search for a service provider. This i...

Code
Sep 25, 2006
Post comments count0
Post likes count0

Waiting until the dialog box is displayed before doing something

Raymond Chen
Raymond Chen

Last time, I left you with a few questions. Part of the answer to the first question was given in the comments, so I'll just link to that. The problem is more than just typeahead, though. The dialog box doesn't show itself until all message traffic has gone idle. If you actually ran the code presented in the original message, you'd find that it ...

Code
Sep 22, 2006
Post comments count0
Post likes count0

Things you already know: How do I wait until my dialog box is displayed before doing something?

Raymond Chen
Raymond Chen

One customer wanted to wait until the dialog box was displayed before displaying its own dialog box. (Personally, I think immediately displaying a doubly-nested dialog box counts as starting off on the wrong foot from a usability standpoint, but let's set that issue aside for now.) The customer discovered that displaying the nested dialog box in r...

Code
Sep 15, 2006
Post comments count0
Post likes count0

Allocating and freeing memory across module boundaries

Raymond Chen
Raymond Chen

I'm sure it's been drilled into your head by now that you have to free memory with the same allocator that allocated it. matches , matches , matches . But this rule goes deeper. If you have a function that allocates and returns some data, the caller must know how to free that memory. You have a variety of ways of accomplishing this. One is to s...

Code
Sep 13, 2006
Post comments count0
Post likes count0

Philosophical discussion on when to mark a method as virtual

Raymond Chen
Raymond Chen

When should you mark a method as virtual? This question has both a technical and a philosophical aspect. The technical aspect is well-understood: You mark a method as virtual if you want calls to the method to be invoked on the run-time type of the invoked object rather than on the compile-time type of the invoking reference. But there is a heavy...

Code
Sep 8, 2006
Post comments count0
Post likes count0

Const pointers: Logical consequences

Raymond Chen
Raymond Chen

Consider this follow-up question to the question from last time: When I call the function, can I assume that the field of the structure will not be modified? If we take a look at the declaration of the function, we see that it reads like this: Go past all the function declaration specification goo and look at the parameter list. It's a ...

Code