mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-24 01:36:58 +00:00
1.6 KiB
1.6 KiB
Core Principles
1. Performance First
Performance is the top priority in all aspects of development. Always ask yourself: "Is the CPU wasting cycles running this code? If so, how do I fix it?".
2. Memory Management
- Heap Allocation Functions Ban: Using memory allocation functions like malloc(), free(), new, and delete is prohibited. Use our custom memory allocator in
src/host/memory/arena.h. Allocating memory should only be done inmain.cduring initialization, otherwise your code will be rejected.
3. Safety First
- Barr C: See the Barr C Style Guide PDF file in the root directory for making Pound's code as safe as possible.
- Error Handling: Every return code from a function must be checked and handled appropriately.
- Assertions: Use assertions to guarantee behavior whenever possible. Watch this video for an explanation: https://youtube.com/shorts/M-VU0fLjIUU
- Static Analysis: Use the SonarQube static analyzer to catch potential bugs early in development.
4. Documentation
Document every struct and function throughout our codebase. This is a tedious task, but it will be greatly appreciated by current and future programmers working on this project.
Style Conventions
See the Barr C style guide for reference. Use clang-format at the root directory to create Barr C compliant code. Here are some non Barr C specific rules:
- Constant First in Equality Tests:
// Non-compliant if (var == constant) if (pointer == NULL) // Compliant if (constant == var) if (NULL == pointer)