I'm trying to perform file manipulation using the envz utilities and I'm having problems using envz_add. I have no problem with envz_get, but when I use envz_add to update a value I get a seg fault.
If anyone has used the envz utilities, I would appreciate the help. Below is an example of what I'm trying to do.
pFile = fopen(file, "r+");
if(pFile != NULL)
{
fseek(pFile, 0, SEEK_END);
size = ftell(pFile);
fseek(pFile, 0, SEEK_SET);
filebuf = malloc(size);
fread(filebuf, size, 1, pFile);
envz_add(&filebuf, &size, key, value); // Seg Fault occurs here filebuf is char *, size is size_t
// key is char[], value is char[]
fclose(pFile);
}