<HTML> <HEAD> <!-- This HTML file has been created by texi2html 1.39 from ./hacking.texi on 12 June 2005 --> <TITLE>Hacking Xconq - Coding Standards</TITLE> </HEAD> <BODY> Go to the <A HREF="hacking_1.html">first</A>, <A HREF="hacking_30.html">previous</A>, <A HREF="hacking_32.html">next</A>, <A HREF="hacking_35.html">last</A> section, <A HREF="hacking_toc.html">table of contents</A>. <HR> <H2><A NAME="SEC33" HREF="hacking_toc.html#SEC33">Coding Standards</A></H2> <P> The <I>Xconq</I> 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. </P> <P> You should allocate by using <CODE>xmalloc</CODE>. 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. </P> <P> There is one exception to this allocation rule, which is that you may use <CODE>malloc</CODE> 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 <CODE>malloc</CODE> 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 <CODE>malloc</CODE> will be unable to allocate the desired memory. </P> <P> Always generate a random number by using <CODE>xrandom</CODE>. This is a generator of known and consistent properties across all systems that <I>Xconq</I> runs on. Consistency is especially critical for ensuring that networked games stay in sync. </P> <P> Indent by 4, with tabs at 8. This is effectively what you get in Emacs if you set <CODE>c-indent-level</CODE> to 4. System-specific interfaces need not adhere to this rule.. </P> <HR> Go to the <A HREF="hacking_1.html">first</A>, <A HREF="hacking_30.html">previous</A>, <A HREF="hacking_32.html">next</A>, <A HREF="hacking_35.html">last</A> section, <A HREF="hacking_toc.html">table of contents</A>. </BODY> </HTML>