本文整理汇总了C++中DB::set_alloc方法的典型用法代码示例。如果您正苦于以下问题:C++ DB::set_alloc方法的具体用法?C++ DB::set_alloc怎么用?C++ DB::set_alloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::set_alloc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rberkeley_db_set_alloc
/* {{{ rberkeley_db_set_alloc */
SEXP rberkeley_db_set_alloc (SEXP _dbp)
{
/* This function allows for memory
from the R process to used for DB
data. Not entirely sure of how to
do this yet, but this is a start... */
DB *dbp;
int ret;
dbp = R_ExternalPtrAddr(_dbp);
if(R_ExternalPtrTag(_dbp) != RBerkeley_DB || dbp == NULL)
error("invalid 'db' handle");
ret = dbp->set_alloc(dbp, malloc, realloc, free);
return ScalarInteger(ret);
}
示例2: rpmGenPath
//.........这里部分代码省略.........
if (oflags & DB_RDONLY)
dbi->dbi_verify_on_close = 0;
if (dbi->dbi_use_dbenv) {
if (rpmdb->db_dbenv == NULL) {
rc = db_init(dbi, dbhome, dbfile, dbsubfile, &dbenv);
if (rc == 0) {
rpmdb->db_dbenv = dbenv;
rpmdb->db_opens = 1;
}
} else {
dbenv = rpmdb->db_dbenv;
rpmdb->db_opens++;
}
}
{ char *dbiflags = prDbiOpenFlags(oflags, 0);
rpmlog(RPMLOG_DEBUG, "opening db index %s/%s %s mode=0x%x\n",
dbhome, (dbfile ? dbfile : rpmTagGetName(dbi->dbi_rpmtag)),
dbiflags, dbi->dbi_mode);
free(dbiflags);
}
if (rc == 0) {
static int _lockdbfd = 0;
rc = db_create(&db, dbenv, dbi->dbi_cflags);
rc = cvtdberr(dbi, "db_create", rc, _debug);
if (rc == 0 && db != NULL) {
if (rc == 0 &&
rpmdb->db_malloc && rpmdb->db_realloc && rpmdb->db_free)
{
rc = db->set_alloc(db,
rpmdb->db_malloc, rpmdb->db_realloc, rpmdb->db_free);
rc = cvtdberr(dbi, "db->set_alloc", rc, _debug);
}
/* 4.1: db->set_cache_priority(???) */
if (rc == 0 && !dbi->dbi_use_dbenv && dbi->dbi_cachesize) {
rc = db->set_cachesize(db, 0, dbi->dbi_cachesize, 0);
rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug);
}
/* 4.1: db->set_encrypt(???) */
/* 4.1: db->set_errcall(dbenv, rpmdb->db_errcall); */
/* 4.1: db->set_errfile(dbenv, rpmdb->db_errfile); */
/* 4.1: db->set_errpfx(dbenv, rpmdb->db_errpfx); */
/* 4.1: db->set_feedback(???) */
if (rc == 0 && dbi->dbi_lorder) {
rc = db->set_lorder(db, dbi->dbi_lorder);
rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
}
if (rc == 0 && dbi->dbi_pagesize) {
rc = db->set_pagesize(db, dbi->dbi_pagesize);
rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug);
}
/* 4.1: db->set_paniccall(???) */
if (rc == 0 && oflags & DB_CREATE) {
switch(dbi->dbi_type) {
default:
case DB_HASH:
if (dbi->dbi_h_ffactor) {
rc = db->set_h_ffactor(db, dbi->dbi_h_ffactor);
rc = cvtdberr(dbi, "db->set_h_ffactor", rc, _debug);
if (rc) break;