Commit Graph

5 Commits

Author SHA1 Message Date
Dan Cross
f74c418f47 clang-format: Minor whitespace issues.
These are entirely my fault, sadly.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-10 10:26:48 +10:00
Dan Cross
54093060cb More cleanups.
More cleaning up construction of arrays of things.
Introduce a utility function called, `split_on_space`
that tokenizes a string on a space character; use
it in most places where `strtok()` had been called.

More use of the ptr_vector type.  Introduce a utility
function to get access to the pointers without consuming
the vector; this is used in the files code.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-10 10:25:47 +10:00
Dan Cross
540e359080 Cleanups and pointer vectors.
A repeated pattern in Magicka is to append to dynamically
sized arrays via malloc()/realloc().  Introduce the notion
of a "pointer vector": that is, a growable vector of
pointers, that can be reused to implement that logic more
safely and efficiently (this implementation uses power-of-two
growing).

Many malloc()/realloc() calls were not checked; these
assert() that the return value from realloc() is not NULL.

Add a method to consume the pointer vector: that is, realloc()
it to the current length and return the underlying pointers.

Make the `fmt` argument to dolog() const.
Include <sys/wait.h> in bluewave.c to squash a warning.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-10 10:25:42 +10:00
Dan Cross
4827dcf8e4 Add a pointer vector abstraction.
There are lots of places where we want a growable
vector of pointers.  Add one.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-10 10:25:37 +10:00
Dan Cross
fa014f3a88 Simplify dynamic memory management.
Add utility routines and use them to simplify the
use of dynamically allocated memory.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-10 10:25:29 +10:00