Retreving the dynamically allocated values from bdb using C
In one of the assignment which i am working on, i am am trying to insert keys and values into BDB by reading the input records from a input file as below.
Here keys i am inserting as character buffer and for values i am dynamically allocating the memory using malloc and then inserting into bdb.
But when i try to retireve the inserted values from BDB i am geting only the latest record for Value.
But when i try to retrive the values from BDB its giving proper values for Key but for Value i am getting only the latest value from input file.
Below is the Key value retreival code.
Can you please suggest how to resolve this ?
Moderator's Comments:
Code tags for code, please.
Last edited by Corona688; 04-11-2012 at 02:31 AM..
In one of the assignment which i am working on, i am am trying to insert keys and values into BDB by reading the input records from a input file as below.
Here keys i am inserting as character buffer and for values i am dynamically allocating the memory using malloc and then inserting into bdb.
But when i try to retireve the inserted values from BDB i am geting only the latest record for Value.
[code]//KEY
char key[512];
//VALUE
typedef struct
{
char *remValues[10];
}valuestr;
static valuestr vstr;
Dbc *dbcObj;
Dbt dbtKey,dbtValue;
// I am dynamically allocating memory for Value str using malloc example as below.
vstr.remValues[0] = (char *)malloc(50);
while(!feof(inFile))
{
//getting key from input file
strcpy(buf, <value1>); //value1 comes from input file
//getting Value from input file
memset(vstr.remValues[0],0,50);
sprintf(vstr.remValues[0],"%d",<value2>); //value2 comes from input file
That would be the case as you are always loading values into the very first element of the array remValues...instead of filling all 10 of them with values read from the input file...which I highlighted in the code above.
Hi All,
I have 2 files which i need to merge together based on the column names provided in the file. The first line in both files are header records.
The first file has fixed columns but second file can have subset of the columns from file 1
File 1:
... (6 Replies)
Hi all,
In ksh, I'm trying to loop through all of my arrays, named array1, array2, array3..., and update the indices. But I'm getting errors and I'm not sure how to fix them. The errors are
./parse.sh: 6+1: not found
The code is:
eval \${array$c}=$(eval \${array$c}+1 )
Any help... (12 Replies)
In one of the assignment which i am working on, i am am trying to insert keys and values into BDB by reading the input records from a input file as below.
Here keys i am inserting as character buffer and for values i am dynamically allocating the memory using malloc and then inserting into bdb.... (1 Reply)
I am needing to create a variable(changing) and assign it a value(changing) ... I am using C-Shell..
Example:
foreach account in ($Accountlist)
set account_connect = "$account/$account_pass"
end
I want to make set account_connect to store various values ? $account_connect did not... (3 Replies)
Actually for a process to run it needs text, stack , heap and data segments. All these find a place in the physical memory.
Out of these 4 only heap does exist after the termination of the process that created it. I want to know the exact reason why this happens. Also why the other process need to... (20 Replies)
I have a pointer to a structure containing an integer pointer:
struct members {
int id;
int *neigh;
};
The number of members N and its neighbors M change as the code runs, so I allocate the memory dynamically:
members *grid = malloc(sizeof(members)*N);
for(i=0;i<N;i++)... (2 Replies)
Hi all,
I am interning in a unix department and am very new to programming. I am supposed to write a script that counts the amount of filesystems a server has allocated, and the amount free. This is what I was given to start with:
#!/bin/ksh
df -m | grep -v ":"|grep -v Free|grep -v "/proc"|... (6 Replies)
i am working with solaris 9 and my disk usages are
# df -k
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c0t0d0s0 2148263 1902721 202577 91% /
/proc 0 0 0 0% /proc
mnttab 0 0 0 ... (3 Replies)
Hi,
I have a server that is getting the following alarm a couple times a day:
Mar 25 10:56:54 hostname xntpd: too many recvbufs allocated (30)
Mar 25 10:56:54 hostname xntpd: too many recvbufs allocated (30)
I know this is some sort of NTP related issue but I need to gauge the severity of... (0 Replies)
Hi,
How to find out what is the maximum memory allocated to TOMCAT server in SunOS 5.8?
The Tomcat server crashes down during peak times....
Regards (1 Reply)