diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-04-30 20:52:26 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-04-30 20:52:26 +0000 |
commit | 6768eb71d8debde65562619c938b997aea1bd9f9 (patch) | |
tree | 93fc4f4a6d66891ace9494b737aa4b2c1bed37ef /sync.c | |
parent | d7ed89eac9580f280fe0017b22c8e38ca75ed8e3 (diff) | |
download | nasm-6768eb71d8debde65562619c938b997aea1bd9f9.tar.gz nasm-6768eb71d8debde65562619c938b997aea1bd9f9.tar.bz2 nasm-6768eb71d8debde65562619c938b997aea1bd9f9.zip |
NASM 0.95
Diffstat (limited to 'sync.c')
-rw-r--r-- | sync.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -7,6 +7,7 @@ */ #include <stdio.h> +#include <stdlib.h> #include <limits.h> #include "sync.h" @@ -21,10 +22,29 @@ static struct Sync { unsigned long pos; unsigned long length; -} synx[SYNC_MAX+1]; /* synx[0] never used - who cares :) */ +} *synx; static int nsynx; void init_sync(void) { + /* + * I'd like to allocate an array of size SYNC_MAX, then write + * `synx--' which would allow numbering the array from one + * instead of zero without wasting memory. Sadly I don't trust + * this to work in 16-bit Large model, so it's staying the way + * it is. Btw, we don't care about freeing this array, since it + * has to last for the duration of the program and will then be + * auto-freed on exit. And I'm lazy ;-) + * + * Speaking of 16-bit Large model, that's also the reason I'm + * not declaring this array statically - by doing it + * dynamically I avoid problems with the total size of DGROUP + * in Borland C. + */ + synx = malloc((SYNC_MAX+1) * sizeof(*synx)); + if (!synx) { + fprintf(stderr, "ndisasm: not enough memory for sync array\n"); + exit(1); + } nsynx = 0; } |