Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> Envz Utilities, Problems using envz utilities
Klinux
post Mar 24 2005, 12:43 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 24-March 05
Member No.: 4,782



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);
}
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
Hemant
post Mar 25 2005, 04:51 AM
Post #2


RMS is my Hero
******

Group: Support Specialist
Posts: 782
Joined: 6-October 02
From: Trichy,INDIA
Member No.: 29



try this...
CODE
...
....

filebuf = (char *)malloc(size);
...
...


The problem might be:

1.Either malloc() has failed
2. Or fread() has failed.

Just tell me which one has actually failed.You can find that out...using strace and gdb.
do a
$strace a.out


--------------------
Hemant Kumar
user posted image
hemant@linuxhelp.net
Go to the top of the page
 
+Quote Post

Posts in this topic
- Klinux   Envz Utilities   Mar 24 2005, 12:43 PM
- - Hemant   try this... CODE... .... filebuf = (char *...   Mar 25 2005, 04:51 AM
- - Klinux   I figured out the problem. The strings in the fil...   Mar 25 2005, 08:43 AM
- - Hemant   I don't know if that's possible.All the fi...   Mar 28 2005, 05:15 AM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th October 2017 - 08:13 AM