本文整理汇总了C++中dispose函数的典型用法代码示例。如果您正苦于以下问题:C++ dispose函数的具体用法?C++ dispose怎么用?C++ dispose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dispose函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_resize
void test_resize(){
ArrayUtil util = create(4, 5);
int * list_array = (int *)(util.base);
list_array[0] = 10;
list_array[1] = 20;
list_array[2] = 30;
list_array[3] = 40;
list_array[4] = 50;
assert(util.length == 5);
ArrayUtil resized_util = resize(util, 7);
assert(resized_util.length = 7);
int * resized_list_array = (int *)(resized_util.base);
assert(resized_list_array[4] == 50);
assert(resized_list_array[5] == 0);
assert(util.length == 5);
assert(list_array[4] == 50);
printf("Array element is not changed\n");
dispose(util);
}
示例2: ev_vbuff_set_capacity
ev_err_t ev_vbuff_set_capacity(ev_vbuff *v, size_t num_bytes)
{
if( v && num_bytes ) {
if( v->size < num_bytes ) {
dispose(v);
}
glGenBuffers(1, &v->id);
if( !v->id )
return EV_FAIL;
ev_vbuff_bind(v);
v->buff = ev_malloc(num_bytes);
if(!v->buff)
return EV_NOMEM;
memset(v->buff, 0, num_bytes);
glBufferData( GL_ARRAY_BUFFER, num_bytes, v->buff, GL_DYNAMIC_DRAW);
v->size = num_bytes;
return EV_OK;
}
return EV_FAIL;
}
示例3: SiegeThrow
void AspModel::initFromFile(std::string filename, const uint32_t importFlags)
{
if (filename.empty())
{
SiegeThrow(Exception, "No filename provided for AspModel::initFromFile()!");
}
std::ifstream file;
if (!utils::filesys::tryOpen(file, filename, std::ifstream::binary))
{
SiegeThrow(Exception, "Failed to open ASP file \""
<< filename << "\": '" << utils::filesys::getLastFileError() << "'.");
}
size_t fileSizeBytes = 0;
utils::filesys::queryFileSize(filename, fileSizeBytes);
if (fileSizeBytes == 0)
{
SiegeWarn("ASP file \"" << filename << "\" appears to be empty...");
// Make this an empty model.
// NOTE: Should this be changed to an error instead?
dispose();
srcFileName = std::move(filename);
return;
}
ByteArray fileContents(fileSizeBytes);
if (!file.read(reinterpret_cast<char *>(fileContents.data()), fileContents.size()))
{
SiegeThrow(Exception, "Failed to read " << utils::formatMemoryUnit(fileContents.size())
<< " from ASP mode file \"" << filename << "\"!");
}
initFromMemory(std::move(fileContents), importFlags, std::move(filename));
}
示例4: set_ttydev
static int set_ttydev(struct cfgdata_t *cfgdata, char *value)
{
const char str_dev[] = "/dev/";
char *p;
/* Check value for 'tty[0-9]' */
if ( ! ( ('t' == value[0]) && ('t' == value[1]) && ('y' == value[2]) &&
(value[3] > '0') && (value[3] < '9') )
) return 0;
/* Prepend '/dev/' to tty name (value) */
p = malloc(sizeof(str_dev)+strlen(value));
if (NULL == p) {
DPRINTF("Can't allocate memory to store tty device name '/dev/%s'", value);
return -1;
}
dispose(cfgdata->ttydev);
cfgdata->ttydev = p;
strcpy(cfgdata->ttydev, str_dev);
strcat(cfgdata->ttydev, value);
return 0;
}
示例5: dispose
CL_GL1FrameBufferProvider::~CL_GL1FrameBufferProvider()
{
dispose();
CL_SharedGCData::remove_disposable(this);
}
示例6: dispose
DocumentSourceCursor::~DocumentSourceCursor() {
dispose();
}
示例7: dispose
MWInfoPage::~MWInfoPage()
{
dispose();
}
示例8: dispose
WorkerContextExecutionProxy::~WorkerContextExecutionProxy()
{
dispose();
}
示例9: dispose
Viewport::~Viewport()
{
dispose();
}
示例11: dispose
SpatialReference::~SpatialReference()
{
dispose();
}
示例12: dispose
InputDeviceProvider_Win32Hid::~InputDeviceProvider_Win32Hid()
{
dispose();
}
示例13: dispose
SpriteNumber::~SpriteNumber(){
dispose();
}
示例14: Send_new_packets
/* ### Pack: this routine has changed */
static int Send_new_packets( int num_allowed )
{
packet_header *pack_ptr;
scatter *scat_ptr;
int pack_entry;
int num_sent;
int ret;
num_sent = 0;
while( num_sent < num_allowed )
{
/* check if down queue is empty */
if( Down_queue_ptr->num_mess == 0 ) break;
/* initialize packet_header */
pack_ptr = new(PACK_HEAD_OBJ);
scat_ptr = Down_queue_ptr->first->mess;
pack_ptr->type = Down_queue_ptr->first->type;
pack_ptr->proc_id = My.id;
pack_ptr->memb_id = Memb_id();
pack_ptr->seq = Highest_seq+1;
Highest_seq++;
pack_ptr->fifo_seq = Highest_fifo_seq+1;
Highest_fifo_seq++;
pack_ptr->data_len = scat_ptr->elements[
Down_queue_ptr->cur_element].len;
Send_pack.elements[1].buf = scat_ptr->elements[
Down_queue_ptr->cur_element].buf;
Down_queue_ptr->cur_element++;
if( Down_queue_ptr->cur_element < scat_ptr->num_elements )
{
/* not last packet in message */
pack_ptr->packet_index = Down_queue_ptr->cur_element;
}else if( Down_queue_ptr->cur_element == scat_ptr->num_elements ){
down_link *tmp_down;
/* last packet in message */
pack_ptr->packet_index = -scat_ptr->num_elements;
tmp_down = Down_queue_ptr->first;
Down_queue_ptr->first = Down_queue_ptr->first->next;
Down_queue_ptr->cur_element = 0;
Down_queue_ptr->num_mess--;
dispose( tmp_down->mess );
dispose( tmp_down );
if( Down_queue_ptr->num_mess < WATER_MARK )
Sess_unblock_users_level();
}else{
Alarm( EXIT,
"Send_new_packets: error in packet index: %d %d\n",
Down_queue_ptr->cur_element,scat_ptr->num_elements );
}
Send_pack.elements[0].buf = (char *) pack_ptr;
Send_pack.elements[1].len = pack_ptr->data_len;
#if 1
ret = Net_queue_bcast( &Send_pack );
#else
ret = Net_bcast( &Send_pack );
#endif
if( ret > 0 )
{
num_sent++;
}
pack_entry = pack_ptr->seq & PACKET_MASK;
if( Packets[pack_entry].exist )
Alarm( EXIT,
"Send_new_packets: created packet %d already exist %d\n",
pack_ptr->seq, Packets[pack_entry].exist );
/* insert new created packet */
Packets[pack_entry].head = pack_ptr;
Packets[pack_entry].body = (packet_body *)Send_pack.elements[1].buf;
Packets[pack_entry].exist = 1;
Packets[pack_entry].proc_index = My_index;
Alarm( PROTOCOL,
"Send_new_packets: packet %d sent and inserted \n",
pack_ptr->seq );
}
ret = Net_flush_bcast();
if( ret > 0 )
{
num_sent++;
}
return ( num_sent );
}
示例15: Prot_handle_token
//.........这里部分代码省略.........
{
Token->aru = My_aru;
Token->aru_last_id = My.id;
if( My_aru < Highest_seq ) Set_aru = My_aru;
else Set_aru = -1;
}else if( Token->aru > My_aru ) {
Token->aru = My_aru;
Token->aru_last_id = My.id;
Set_aru = My_aru;
}else{
Set_aru = -1;
}
Token->proc_id = My.id;
if( Memb_state() != EVS ) Token->seq = Highest_seq;
if( Conf_leader( Memb_active_ptr() ) == My.id )
{
val = Get_arq( Token->type );
val = (val + 1)% 0x10;
Token->type = Set_arq( Token->type, val );
Token->type = Set_retrans( Token->type, 0 );
}
/* Send token */
if( ! ( Conf_leader( Memb_active_ptr() ) == My.id &&
To_hold_token() ) )
{
/* sending token */
Net_send_token( &New_token );
/* ### Bug fix for SGIs */
#ifdef ARCH_SGI_IRIX
Net_send_token( &New_token );
#endif /* ARCH_SGI_IRIX */
if( Get_retrans( Token->type ) > 1 )
{
/* problems */
Net_send_token( &New_token );
Net_send_token( &New_token );
}
}
Token_rounds++;
if( Conf_leader( Memb_active_ptr() ) == My.id )
E_queue( Prot_token_hurry, 0, NULL, Hurry_timeout );
E_queue( Memb_token_loss, 0, NULL, Token_timeout );
/* calculating Aru */
if( Token->aru > Last_token->aru )
Aru = Last_token->aru;
else
Aru = Token->aru;
if( Highest_seq == Aru ) Token_counter++;
else Token_counter = 0;
dispose( Last_token );
Last_token = Token;
New_token.elements[0].buf = (char *) new(TOKEN_HEAD_OBJ);
New_token.elements[1].len = sizeof(token_body);
Token = (token_header *)New_token.elements[0].buf;
/* Deliver & discard packets */
Discard_packets();
Deliver_agreed_packets();
Deliver_reliable_packets( Highest_seq-num_sent+1, num_sent );
if( Memb_state() == EVS && Token_rounds > MAX_EVS_ROUNDS )
{
Alarmp( SPLOG_ERROR, PRINT, "Prot_handle_token: BUG WORKAROUND: Too many rounds in EVS state; swallowing token; state:\n" );
Alarmp( SPLOG_ERROR, PRINT, "\tAru: %d\n", Aru );
Alarmp( SPLOG_ERROR, PRINT, "\tMy_aru: %d\n", My_aru );
Alarmp( SPLOG_ERROR, PRINT, "\tHighest_seq: %d\n", Highest_seq );
Alarmp( SPLOG_ERROR, PRINT, "\tHighest_fifo_seq: %d\n", Highest_fifo_seq );
Alarmp( SPLOG_ERROR, PRINT, "\tLast_discarded: %d\n", Last_discarded );
Alarmp( SPLOG_ERROR, PRINT, "\tLast_delivered: %d\n", Last_delivered );
Alarmp( SPLOG_ERROR, PRINT, "\tLast_seq: %d\n", Last_seq );
Alarmp( SPLOG_ERROR, PRINT, "\tToken_rounds: %d\n", Token_rounds );
Alarmp( SPLOG_ERROR, PRINT, "Last Token:\n" );
Alarmp( SPLOG_ERROR, PRINT, "\ttype: 0x%x\n", Last_token->type );
Alarmp( SPLOG_ERROR, PRINT, "\ttransmiter_id: %d\n", Last_token->transmiter_id );
Alarmp( SPLOG_ERROR, PRINT, "\tseq: %d\n", Last_token->seq );
Alarmp( SPLOG_ERROR, PRINT, "\tproc_id: %d\n", Last_token->proc_id );
Alarmp( SPLOG_ERROR, PRINT, "\taru: %d\n", Last_token->aru );
Alarmp( SPLOG_ERROR, PRINT, "\taru_last_id: %d\n", Last_token->aru_last_id );
Alarmp( SPLOG_ERROR, PRINT, "\tflow_control: %d\n", Last_token->flow_control );
Alarmp( SPLOG_ERROR, PRINT, "\trtr_len: %d\n", Last_token->rtr_len );
Alarmp( SPLOG_ERROR, PRINT, "\tconf_hash: %d\n", Last_token->conf_hash );
Memb_token_loss();
}
GlobalStatus.highest_seq = Highest_seq;
GlobalStatus.aru = Aru;
GlobalStatus.token_rounds = Token_rounds;
}