This page summarizes the changes in the source code from C Interfaces and Implementations in reverse chronological order. For more information about this book, see the World-Wide Web page at http://www.cs.princeton.edu/software/cii/.
In the list below, notations like [p. 442] refer to the pages on which the corrections appear; see the errata for the first and second printings.
src/array.c:Array_resize so that it correctly resizes empty
arrays and handles a new size of 0 [p. 168].Array_copy(a, len) so that it correctly copies the
elements of a when Array_length(a) == len [p. 169].src/arena.c:Arena_alloc to avoid
undefined behavior [p. 94].MAXALIGN is defined, it gives the platform's maximum
alignment in bytes and is used instead of sizeof (union align).
MAXALIGN is needed only when the maximum alignment is not equal to
sizeof (union align).include/except.h, src/except.c:WIN32 is
defined), declared Except_stack to be thread local storage.src/mem.c:NALLOC so that allocated blocks are
properly aligned [p. 84].src/memchk.c:MAXALIGN is defined, it gives the maximum alignment; see
src/arena.c above.src/{thread.c,swtch.s}:src/thread.c, corrected assertion to
catch Thread_join(Thread_self()) [p. 442].src/thread-nt.c:In addition to the changes itemized below, the following global changes were made.
Mem_calloc that initialized pointers with
explicit assignments, because null pointers may be nonzero.qsort and
Thread_new, so that they match the prototypes of the corresponding
formal parameters, which avoids the implicit assumption that all object pointer
types have the same size and representation.Mem and Atom functions and
macros to conform to the revised interfaces (see below).strerror to printing a more detailed
diagnostic.{wf,xref}/*.[ch]:first(char c) and rest(char c) to
first(int c) and rest(int c).src/arena.[ch]:nbytes and count
arguments to Arena_alloc and Arena_calloc from
int to long.src/assert.h:#undef assert.Assert_Failed to except.h
so that assert.h is plug-compatible with an ANSI/ISO assert.h.src/atom.[ch]:Atom_new, Atom_string,
and Atom_int from char * to const char *.src/except.h:Assert_Failed.Except_flag volatile.src/list.h:first and rest
fields.src/mem.[ch]:nbytes and count
arguments to Mem_alloc, Mem_calloc, and Mem_resize
from int to long.Mem_free and Mem_resize to accept
pointers to the blocks to be deallocated or resized instead of pointers to those
pointers; the arguments to these functions now mimic the arguments for malloc
and realloc.FREE(ptr): it frees the block pointed to by ptr
and clears ptr; it evaluates ptr more than once.RESIZE(ptr, nbytes): it resizes the block pointed to
by ptr and reaims ptr at the resized block; it
evaluates ptr more than once.src/mp.c:MP_fromint, MP_addi,
MP_subi, MP_muli, MP_divi, and MP_modi,
which were incorrect on platforms where sizeof (long) exceeds
sizeof (int).MP_mul and MP_mulu, which scribbled
beyond the end of z, their result arguments.base to MP_tostr.This beta release is the last one before release 1.0, which will coincide with the publication of C Interfaces and Implementations in August 1996.
There are too many bug fixes to list individually here, so the following summary describes only the interface changes and the new examples.
cref/*.c:xref that uses Text and Ring.iref/*.c:xref that uses Text, Array,
and MP.idents/*.c:ids that uses Str and Seq.kref/*.c:xref that uses Str and Seq.words/*.c:ids that uses Text and Ring.src/bit.h:Bit_length to Bit_count, Bit_size
to Bit_length, Bit_member to Bit_get,
and removed
Bit_remove.Bit_remove.Bit_put to Bit_put(set, n, bit), which
now sets bit n in set to bit and
returns the previous value of bit n.src/except.h:Except_flag.src/ring.h:Ring_put(ring, i, x) so it returns the previous value
of
ring[i] instead of x.src/seq.h:Seq_put(seq, i, x) so it returns the previous value
of
seq[i] instead of x.src/set.h:Set_cvt to Set_fmt.src/str.h:Str_cvt to Str_fmt.src/table.h:Table_put(table, key, value) so it returns the
previous value associated with key instead of value,
or null if table doesn't hold key.src/text.h:str field in Text_T to const
char *str.Text_cvt to Text_fmt.src/xp.h:XP_add, XP_sub,
XP_sum, XP_diff, XP_product, XP_quotient,
and XP_neg, and XP_fromstr to int,
and changed the type of the last argument (carry, borrow,
or y) to these functions to int.XP_fromstr to int.XP_mul to int XP_mul(T z, int
n, T x, int m, T y) so n and m precede the
T values to which they apply.XP_div to int XP_div(int n, T
q, T x, int m, T y, T r, T tmp) so n and m
precede the T values to which they apply .fill) to XP_lshift
and XP_lshift to int.`const' qualifiers have been added to some of the arguments in
many of the interfaces. The source files have been stamped with an RCS-like
revision numbers. C++ keywords are no longer used as variables.
calc/calc.c:_ to ~.mpcalc/mpcalc.c:_ and ~,
to ~ and !.src/atom.h:Atom_new now accepts zero-length strings.src/atom.c:Atom_new to accept len=0.src/bit.h:Bit_cmp.Bit_eq, Bit_leq, and Bit_lt.src/bit.c:Bit_cmp,
and added implementations for Bit_eq, Bit_leq, and
Bit_lt.src/except.h:RETURN_VOID and changed the definition of RETURN
so that it subsumes RETURN_VOID.src/ring.c:Ring_rotate so that Ring_rotate(r, 0)
when
r is empty works.src/set.h:cmp(x,y) function passed to Set_new must
now return an integer <0, =0, or >0 if x<y,
x=y, or x>y.src/str.c:va_start in Str_catv.src/swtch.s:src/table.h:cmp(x,y) function passed to Table_new must
now return an integer <0, =0, or >0 if x<y,
x=y, or x>y.src/table.c:Table_remove that caused
entries not to be removed.src/thread.h:Thread_Failed; Thread_new raises Thread_Failed
when it cannot create a thread, instead of Mem_Failed.src/thread.c:memset in Thread_new,
and changed Thread_new to raise Thread_Failed.Thread_new.Initial beta release.