15.3.1 Splitting the C-Language Source File

So that the functions within the file are compiled as separate segments, you must split the C-language source file into separate files. For this application, you can split the source file into four parts, as described in the following list:

Source file Content

MEMORY1.C Contains the WinMain function. Because Windows executes the message loop in WinMain frequently, the segment created from this source file is not discardable. This prevents a situation in which the segment has to be loaded from the disk often. Because WinMain is relatively small anyway, keeping this segment in memory has little effect on available global memory.
MEMORY2.C Contains the MemoryInit function. Since the MemoryInit function is used only when the application first starts, the segment created from this source file can be discardable.
MEMORY3.C Contains the MemoryWndProc function. Although the segment created from this source file can be discardable, the MemoryWndProc function is likely to be called at least as often as the WinMain function receives control. In this case, the segment is movable but not discardable.
MEMORY4.C Contains the About function. Since the About function is seldom called (only when the About dialog box is displayed), the code segment created from this source file can be discardable.

You must include the WINDOWS.H and MEMORY.H header files in each source file.