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.
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
...........
...........
//Putting values into BDB
dbtKey.set_data((char*) buf);
dbtKey.set_size(strlen(buf));
dbtValue.set_data((valuestr*)&vstr);
dbtValue.set_size(sizeof(valuestr));
int ret = dbObj.put(0,&dbtKey,&dbtValue,DB_NOOVERWRITE);
}
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.
Code:
dbObj.cursor(NULL,&dbcObj,0);
char keys[100];
valuestr *values;
while(dbcObj->get(&dbtKey,&dbtValue,DB_NEXT)==0)
{
memset(keys,0,sizeof(keys));
strncpy(keys,(char *)dbtKey.get_data(),strlen(buf));
values = (valuestr *)dbtValue.get_data();
//printing values and keys on to console
}
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..
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)
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)
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 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 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)
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 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)
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)
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)
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)
Discussion started by: kushagra
6 Replies
LEARN ABOUT OPENDARWIN
bdb.db0
BDB.DB0(5) AFS File Reference BDB.DB0(5)NAME
bdb.DB0, bdb.DBSYS1 - Contain the Backup Database and associated log
DESCRIPTION
The bdb.DB0 file contains the Backup Database, which records configuration information used by the AFS Backup System along with cross-
indexed records of the tapes created and volumes dumped using the Backup System commands.
The bdb.DBSYS1 file is a log file in which the Backup Server (buserver process) logs each database operation before performing it. When an
operation is interrupted, the Backup Server replays the log to complete the operation.
Both files are in binary format and reside in the /var/lib/openafs/db directory on each database server machine that runs the Backup
Server. When the Backup Server starts or restarts on a given machine, it establishes a connection with its peers and verifies that its
copy of the bdb.DB0 file matches the copy on the other database server machines. If not, the Backup Servers use AFS's distributed database
technology, Ubik, to distribute to all of the machines the copy of the database with the highest version number.
Use the commands in the backup suite to administer the Backup Database. It is advisable to create a backup copy of the bdb.DB0 file on tape
on a regular basis, using the UNIX tar command or another local disk backup utility.
SEE ALSO backup(8), backup_savedb(8), buserver(8)COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved.
This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas
Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell.
OpenAFS 2012-03-26 BDB.DB0(5)