Zipvfs

Design Rules
Login

Design Rules

Principles

  1. Cross-platform. The code can be compiled and run on multiple platforms: big-endian and little-endian, 32-bit and 64-bit. Database files also are fully portable between platforms - the file format is platform independent.

  2. Backwards compatible. Future releases of ZIPVFS should be a drop-in replacement for the current release. The interface and file format are binary compatible between releases.

  3. Principle of Least Surprise. The code does what programmers expect.

  4. Self-contained. Minimal external dependences.

  5. Timeless. The code is intended to have a useful lifespan of decades. The code is readable, understandable, and maintainable by people not yet born.

Constraints

  1. No large stack frames. The system runs with 2K or less of stack space.

  2. Bounded recursion.

  3. No large memory allocations. The maximum memory allocation size is proportional to the size of the largest data row read or written, or the database page size, whichever is greater.

  4. Minimal library support. Use SQLite-supplied utilities and services wherever possible. Acceptable routines from the standard library:

    • memcpy()
    • memset()
    • memmove()
    • strcmp()

  5. Threadsafe but not threaded. ZIPVFS does not use threads itself but is safe to use within a multi-threaded application.

Robustness

  1. I/O errors either self-correct or report back up to the application.

  2. Corrupt database files are detected and reported back up to the application.

  3. OOM errors are detected and handled either by making due without the requested memory or by reporting the error back up to the application.

  4. No resource leaks. All resources are returned to the system when no longer required. This is true even following OOM errors, I/O errors, or other system problems.

Naming Conventions

  1. All exported symbols begin with "zipvfs_". Any symbol that begins with "zipvfs_" is exported.

  2. The only exported symbols are the defined and documented interfaces.

  3. Exported symbols are lower-case with "_" seperating words.

  4. Exported macros begin with "ZIPVFS_" or "SQLITE_".