[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory management for io_read(), etc.

From: Andrew Eggenberger
Subject: Re: Memory management for io_read(), etc.
Date: Sat, 24 Apr 2021 17:29:23 -0500

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:

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

if I change it to

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

[Prev in Thread] Current Thread [Next in Thread]