The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
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. 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 state explicitly how the memory should be freed. For example, the documentation explicitly states that you should use the function to free the buffer that is allocated if you pass the flag. All s must be freed with . And all memory returned across COM interface bound...
The lost follow-ups: Products and people that appear to have vanished without a trace
There'll be the big announcement promising a revolution in the computer industry, lots of press coverage, and then... nothing. What ever happened to these companies and products? Does anybody know?
The danger of using boldface for Chinese characters
Intricacies become lost in the ink.
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 collection was 4th Ikimasshoi! (4th いきまっしょい! = 4th Let's Go!), the um fourth album from the J-Pop group Morning Musume (モーニング娘 = Morning Girls). I'm sure somebody will correct my Jap...
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 heavy philosophical aspect to this question as well. Some people argue that every method should be virtual so that derived classes can override the behavior of the base class in ways the base class may not have anticipated. This grants you maximum flexibility, avoiding havin...
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 often. This is a verb+particle combination and is treated as two words. When you turn it into a noun, however, it becomes "shutdown", one word. This Knowledge Base article, for example, manages to keep its head on straight for most of the article, using the verb+particle f...
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, I don't want you to recycle those songs. I want to keep the songs. Just delete the playlist," you say to yourself and you click "No". Unfortunately, the program was asking you, "Do you want to move the songs to the Recycle Bin or delete the songs permanently from your com...
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 particularly notable to the researchers was that even just five hours of exposure made a significant impact.
Const pointers: Logical consequences
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 pointer to a structure (either ANSI or Unicode, depending on which flavor of the function you're calling). One of the rules for const pointers is that you can read from them but you cannot write to them. Consequently, the function is not allowed to modify the str...