Commit Graph

18 Commits

Author SHA1 Message Date
Andrew Pamment
af8936c02e Haiku Support
Hope I didn't break things!
2018-10-18 11:36:02 +10:00
Dan Cross
359a190ee9 Remove the last of the sprintf() calls.
sprintf() is unsafe since it may overflow the bounds
of its destination buffers.  Remove the last of the
calls to it; all the logic has either been rewritten
to use snprintf() or other forms of string copying
such as strlcpy().

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-17 13:11:33 +10:00
Dan Cross
6d30116ed9 Import strlcpy/strlcat from OpenBSD, start using them.
strcpy()/strcat() are inherently dangerous, even when
used with great care.  strlcpy() and strlcat() are
much safer replacements, and are available from OpenBSD
under a very liberal license.  Import them and start
using them.

Between pointer vectors, malloz, stralloc and now
strlcpy/strlcat, Magicka has much safer, simpler and
more performant infrastructure for dealing with
strings and dynamic collections of various kinds.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-11 13:58:49 +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
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
Dan Cross
d6826137dd clang-format
Fix a bunch of trivial formatting issues by running
`clang-format`.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-09 15:48:42 +10:00
Andrew Pamment
4b90398cbf Stop using system() 2018-06-20 19:39:57 +10:00
Andrew Pamment
edb1b41652 Git hooks suck 2018-06-05 15:27:53 +10:00
Andrew Pamment
d14af4bf23 i will get this soon 2018-06-05 15:24:42 +10:00
Andrew Pamment
f12630f7e5 Last test commit 2018-06-05 15:23:30 +10:00
Andrew Pamment
ffd1c546b8 Another test commit 2018-06-05 15:21:49 +10:00
Andrew Pamment
1feaa7d91e Another test commit 2018-06-05 15:19:41 +10:00
Andrew Pamment
b472f6448c Test commit, just whitespace 2018-06-05 15:15:14 +10:00
Andrew Pamment
f5cd8ddb03 Remove IAC debug output 2018-02-05 11:52:01 +10:00
Andrew Pamment
027c047b42 some debugging IAC codes in file transfers 2018-02-01 13:42:57 +10:00
Andrew Pamment
5543f94e01 Magicka now builds and runs on SunOS 2017-10-20 07:27:58 +10:00
Andrew Pamment
ffaca86565 Redo Make file setup.. please standby 2017-09-25 13:27:22 +10:00