Andrew Eggenberger, le jeu. 22 avril 2021 20:37:02 -0500, a ecrit: > But when I try to do the same in my translator, I get a "free(): invalid > pointer" > error. Here is the relevant portion of my code. > > filebuf = malloc(s.st_size + 1); > err = io_read(innerdir, &filebuf, &amt_written, 0, s.st_size); > free(filebuf);
Note that the RPC may replace filebuf with its own vm_allocate()-ed buffer. The guide should not be documenting the use of malloc(), that's confusing. Either the program has an already-allocated buffer to put the data directly in, that it won't actually want to free. Or it wants to allocate dynamically, and it's simpler to just make it NULL so the RPC does the allocation. Possibly on successive RPC calls it's useful to reuse an allocation, and eventually use vm_deallocate(), but surely not free(). Samuel
