\def\TITLE{Developer's Guide to the PARI library}
\input parimacro.tex
\ifPDF % PDF output (from pdftex)
  \input pdfmacs.tex
\fi

% START TYPESET
\begintitle
\vskip 2.5truecm
\centerline{\mine Developer's Guide}
\vskip 1.truecm
\centerline{\mine to}
\vskip 1.truecm
\centerline{\mine the PARI library}
\vskip 1.truecm
\centerline{\sectiontitlebf (version \vers)}
\vskip 1.truecm
\authors
\endtitle

\copyrightpage
\tableofcontents
\openin\std=develop.aux
\ifeof\std
\else
  \input develop.aux
\fi
\chapno=0

\chapter{Work in progress}

This draft documents private internal functions for hard-core PARI
developers. Anything in here is liable to change on short notice. Don't
use anything in there, unless you are implementing new features for
the PARI library. Try to fix the interfaces before using them.
If you find an undocumented hack somewhere, add it here.

Hopefully, this will eventually document everything that we burried in
\kbd{paripriv.h} or even more private header files like \kbd{anal.h}.
Possibly, even implementation choices ! Way to go.

\section{Growarrays}

A \teb{growarray} is a container type, wich enlarges itself as one appends
elements to it. It has the following fields, accessed as \kbd{A->v},
\kbd{A->len}, \kbd{A->n}:

  \kbd{v}: an array of values, of type \kbd{void*}, possibly from $0$ to
$\kbd{len}-1$, the ones from $0$ to $\kbd{n}-1$ being occupied. This array
is allocated using \kbd{malloc}, not on the PARI stack.

  \kbd{len}: the number of cells allocated in \kbd{v}.

  \kbd{n}: the number of occupied cells.

\noindent These containers are used when initializing the library, before the
PARI stack is available, hence allocate memory using \kbd{malloc(3)}, not on
the stack. They are manipulated with the following functions.

\fun{void}{grow_init}{growarray A} initialize the \kbd{growarray} \kbd{A}.

\fun{void}{grow_append}{growarray A, void *e} append \kbd{e} to \kbd{A},
enlarging \kbd{A} if necessary.

\fun{void}{grow_copy}{growarray A, growarray B} creates a copy \kbd{B} of
\kbd{A}. Do not initialize \kbd{B} first (memory leak otherwise). If 
\kbd{A} is \kbd{NULL}, this has the same effect as \kbd{grow\_init(B)}.

\fun{void}{grow_kill}{growarray A} frees \kbd{A}

\vfill\eject
\input index\end
