Thanks! But now I'm getting a segfault when I try to vm_deallocate. It
seems to be the result of calling memchr on the vm_allocated buffer. Here
is the function that calls memchr:

int
binaryfilep(char* buf)
{
  return memchr(buf, '\0', 1024) != NULL;
}

if I change it to

int
binaryfilep(char* buf)
{
  return 1;
}

I'm able to use vm_deallocate.

The whole sequence looks like this:

err = io_read(innerdir, (char**)&filebuf, &amt_written, 0, s.st_size + 1);

isbinfile = binaryfilep((char*)filebuf);

vm_deallocate(mach_task_self(), (vm_offset_t)filebuf, filebufsize);

memchr returns a pointer to the first instance of the char argument, but
does it also change where its first argument points?


*Andrew Eggenberger*

Reply via email to