Preface Part Ⅰ. C Patterns 1.ErrorHandling Running Example Function Split Guard Clause Samurai Principle Goto Error Handling Cleanup Record Object—Based Error Handling Summary Further Reading 0uflook 2.Returning Error Information Running Example Return Status Codes Return Relevant Errors Special Return Values Log Errors Summary Further Reading 0utlook 3.MemowManagement Data Storage and Problems with Dynamic Men Running Example Stack First Eternal Memory Lazy Cleanup Dedicated Ownership Allocation Wrapper Pointer Check Memory Pool Summary Further Reading 0utlook 4.ReturningDatafromC Functions Running Example Return V甜ue out.Parameters Aggregate Instance Immutable Instance Caller.Owned Buffer Callee燦locates Summary 0utlook 5.Data LifetimeandOwnership Stateless Software—Module Software.Module with Global State Caller.Owned Instance Shared Instance
Summary Further Reading Outlook 6.FlexibleAPIs Header Files Handie Dynamic Interfaca Function Control Summary Further Reading 0utlook 7.Flexible Iterator Interfaces Running Example Index Access Cursor Iterator Callback Iterator Summary Further Reading Outlook 8.Organizing Files in Modular Programs Running Example Include Guard Software—Module Directories Global Include Directory Self-Contained Component APICopy Summary 0utlook 9.Escaping#ifdefHell Running Example AvoidVariants Isolated Primitives Atomic Primitives Abstraction Layer Split Variant Implementations Summary Further Reading 0utlook Part Ⅱ.Pattern Stories lO.Implementing Logging Functionality The Pattern Story File Organization Central Logging Function Logging Source Filter Conditional Logging Multiple Logging Destinations File Logging Cross—Platform Files Using the Logger Summary
11.Buildinga UserManagementSystem The Pattern Story Data Organization File Organization Authentication:Error Handling Authentication:Error Logging Adding Users:Error Handling Iterating Using the User Management System Summary 12.Conclusion What You've Learned Further Reading Closing Remarks lndex