0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-10-10 00:25:06 -04:00

applied theowl's patch to raa_write - errors to raa_read

This commit is contained in:
Frank Kotler
2002-05-18 07:26:18 +00:00
parent 8e4994d034
commit 8a273b078d

View File

@@ -367,14 +367,14 @@ void raa_free (struct RAA *r)
long raa_read (struct RAA *r, long posn) long raa_read (struct RAA *r, long posn)
{ {
if (posn > r->stepsize * LAYERSIZ(r)) if (posn > r->stepsize * LAYERSIZ(r))
return 0L; nasm_malloc_error (ERR_PANIC, "bad position in raa_read");
while (r->layers > 0) { while (r->layers > 0) {
ldiv_t l; ldiv_t l;
l = ldiv (posn, r->stepsize); l = ldiv (posn, r->stepsize);
r = r->u.b.data[l.quot]; r = r->u.b.data[l.quot];
posn = l.rem; posn = l.rem;
if (!r) /* better check this */ if (!r) /* better check this */
return 0L; nasm_malloc_error (ERR_PANIC, "null pointer in raa_read");
} }
return r->u.l.data[posn]; return r->u.l.data[posn];
} }
@@ -395,7 +395,7 @@ struct RAA *raa_write (struct RAA *r, long posn, long value)
s = nasm_malloc (BRANCHSIZ); s = nasm_malloc (BRANCHSIZ);
memset (s->u.b.data, 0, sizeof(r->u.b.data)); memset (s->u.b.data, 0, sizeof(r->u.b.data));
s->layers = r->layers + 1; s->layers = r->layers + 1;
s->stepsize = RAA_LAYERSIZE * r->stepsize; s->stepsize = LAYERSIZ(r) * r->stepsize;
s->u.b.data[0] = r; s->u.b.data[0] = r;
r = s; r = s;
} }