The Old New Thing

Allocating and freeing memory across module boundaries

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. LocalAlloc matches LocalFree, GlobalAlloc matches GlobalFree, new[] matches delete[]. 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...
Comments are closed.0 0
Code

The danger of using boldface for Chinese characters

Take care not to hard-code boldfacing or italics into your code. Chinese and Japanese characters (and to a somewhat lesser extent, Korean characters) do not suffer many types of boldface well. (The three scripts Chinese, Japanese and Korean are collectively called "CJK" scripts.) Many characters are very intricate, and making the strokes ...
Comments are closed.0 0
Code

Raymond's excursions into East Asian pop music, episode 3: Morning Musume (モーニング娘)

It really all started with Katamari Damacy (塊魂). The music for that game is so darned infectious, and it was my fascination with that music that prompted my colleague to loan me the CDs his wife bought while she traveled through Asia. I already mentioned China Dolls (中國娃娃). Another of the CDs in the ...

Philosophical discussion on when to mark a method as virtual

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 ...
Comments are closed.0 0
Code

Grammar review: Verb+particle versus compound noun

Although the inflections and compound-mania are largely absent from the English language, there are still some vestiges of its Germanic roots. One detail of English grammar that I often see neglected is the distinction between the verb+particle and the compound noun. Consider the verb phrase "to shut down", which is the one I see misused most...

If you ask a Yes/No question, make sure the user also knows what happens when they say No

I was talking with someone last year who had a gripe about a music organizer program. Suppose you create some playlists and then decide, "Oh, nevermind, I don't like this playlist." You highlight the playlist and click "Delete". You then get a dialog box that asks, "Do you want to move the songs in this playlist to the Recycle Bin?" "Well, no...

Turns out you can't learn Mandarin Chinese by watching television

It is generally accepted that language exposure in the first year of a baby's life is important. To what certainly must be the dismay of couch potatoes everywhere, researchers at the University of Washington determined that it's particularly important that it come from a live human being. Watching DVDs doesn't have any effect. What was ...

Const pointers: Logical consequences

Consider this follow-up question to the question from last time: When I call the PropertySheet function, can I assume that the phpage field of the PROPSHEETHEADER structure will not be modified? If we take a look at the declaration of the PropertySheet function, we see that it reads like this: Go past all the function declaration ...
Comments are closed.0 0
Code

What you don't apologize for is as important as what you do

In the aftermath of the Zidane head-butt incident, there was a lot of speculation over what Materazzi might have said to provoke Zidane's response. Zidane has said he attacked Materazzi because he insulted his mother and sister. Materazzi denied disparaging Zidane's mother. I immediately noticed the very precise denial from Materazzi. (I ...

Feedback usabilla icon