Mail Archives: djgpp/1996/04/29/01:46:09
On Sat, 27 Apr 1996, Jag wrote:
> > Could you post the contents of function read_t2?
> >
>
> void fread_t2(char p_a, char *s_a, int l_c) /* read x amount of bytes */
> { /* start_addr, string, count */
> int handle, l_a;
> handle = _open( s_a, 0);
> if (handle != -1)
> {
> l_a = _read(handle, p_a, l_c);
If the above is the EXACT copy of the actual source, then the problem is
that you tell `fread_t2' that the address of the buffer is a char, when
it should be a pointer to char. That is, you should write this:
void fread_t2 (char *p_a, char *s_a, int l_c)
(I also suggest making `l_c' a size_t, but that's another story). The
way you did it, `fread_t2' gets a pointer (&table[0]) which is
32bit-wide, but because it thinks the first argument is a char
(8bit-wide) it takes its least-significant byte and passes it to `_read'
as an address of a buffer to move data to. Chances are this address is
outside your address space, and the `__dj_movedata' (which is a low-level
function that actually moves the data being read to the buffer pointed to
by that address) gets blown off by the memory protection.
When you add other arrays, you change the addresses in a way that can
make the least-significant byte be a legal address, but I doubt that the
data ends up where you think it should be even then.
- Raw text -