/** * B U _ P T B L * * This version maintained for source compatibility with existing NMG code. */ int bu_ptbl(struct bu_ptbl *b, int func, long int *p) { if (func == BU_PTBL_INIT) { bu_ptbl_init(b, 64, "bu_ptbl() buffer[]"); return 0; } else if (func == BU_PTBL_RST) { bu_ptbl_reset(b); return 0; } else if (func == BU_PTBL_INS) { return bu_ptbl_ins(b, p); } else if (func == BU_PTBL_LOC) { return bu_ptbl_locate(b, p); } else if ( func == BU_PTBL_ZERO ) { bu_ptbl_zero(b, p); return( 0 ); } else if (func == BU_PTBL_INS_UNIQUE) { return bu_ptbl_ins_unique(b, p); } else if (func == BU_PTBL_RM) { return bu_ptbl_rm(b, p); } else if (func == BU_PTBL_CAT) { bu_ptbl_cat( b, (const struct bu_ptbl *)p ); return(0); } else if (func == BU_PTBL_FREE) { bu_ptbl_free(b); return (0); } else { BU_CK_PTBL(b); bu_log("bu_ptbl(%8x) Unknown table function %d\n", b, func); bu_bomb("bu_ptbl"); } return(-1);/* this is here to keep lint happy */ }
struct db_i * db_clone_dbi(struct db_i *dbip, long int *client) { RT_CK_DBI(dbip); dbip->dbi_uses++; if (client) { bu_ptbl_ins_unique(&dbip->dbi_clients, client); } return dbip; }
/** * B U _ P T B L _ C A T _ U N I Q * * Catenate one table onto end of another, * ensuring that no entry is duplicated. * Duplications between multiple items in 'src' are not caught. * The search is a nasty n**2 one. The tables are expected to be short. */ void bu_ptbl_cat_uniq(struct bu_ptbl *dest, const struct bu_ptbl *src) { register long **p; BU_CK_PTBL(dest); BU_CK_PTBL(src); if (bu_debug & BU_DEBUG_PTBL) bu_log("bu_ptbl_cat_uniq(%8x, %8x)\n", dest, src); /* Assume the worst, ensure sufficient space to add all 'src' items */ if ((dest->blen - dest->end) < src->end) { dest->buffer = (long **)bu_realloc( (char *)dest->buffer, sizeof(long *)*(dest->blen += src->blen + 8), "bu_ptbl.buffer[] (cat_uniq)"); } for ( BU_PTBL_FOR( p, (long **), src ) ) { bu_ptbl_ins_unique( dest, *p ); } }