Go to the first, previous, next, last section, table of contents.

Coding Standards

The Xconq sources adhere to a number of coding standards that you should follow also. While everyone has their individual style, it is important to the code's maintenance that the existing style be preserved.

You should allocate by using xmalloc. This routine checks for allocation validity and gives a useful error message if allocation fails, it zeroes the block so you can count on the newly allocated space being in a known state, and it collects statistical data, which is important to optimization.

There is one exception to this allocation rule, which is that you may use malloc if you intend to free the memory shortly. An example would be temporary working space needed by an interface. However, you must then check the return result from malloc yourself and handle failures appropriately; remember that players can easily ask for very large games, so it's quite possible that any given call to malloc will be unable to allocate the desired memory.

Always generate a random number by using xrandom. This is a generator of known and consistent properties across all systems that Xconq runs on. Consistency is especially critical for ensuring that networked games stay in sync.

Indent by 4, with tabs at 8. This is effectively what you get in Emacs if you set c-indent-level to 4. System-specific interfaces need not adhere to this rule..

Go to the first, previous, next, last section, table of contents.