/***************************************************************************** * The test session */ static void test_destroy(void) { if (g_app.tx) stream_destroy(g_app.tx); if (g_app.tx_wav) pjmedia_port_destroy(g_app.tx_wav); if (g_app.rx) stream_destroy(g_app.rx); if (g_app.rx_wav) pjmedia_port_destroy(g_app.rx_wav); if (g_app.loop) pjmedia_transport_close(g_app.loop); if (g_app.endpt) pjmedia_endpt_destroy( g_app.endpt ); if (g_app.log_fd) { pj_log_set_log_func(&pj_log_write); pj_log_set_decor(pj_log_get_decor() | PJ_LOG_HAS_NEWLINE); pj_file_close(g_app.log_fd); g_app.log_fd = NULL; } if (g_app.pool) pj_pool_release(g_app.pool); pj_caching_pool_destroy( &g_app.cp ); pj_shutdown(); }
t_stream* spock_serialize(t_spock* spock) { int offset = 0; t_stream* stream_spock = stream_create(sizeof(spock->edad) + strlen(spock->nombre) + 1); memcpy(stream_spock->data + offset, &spock->edad, sizeof(spock->edad)); offset += sizeof(spock->edad); memcpy(stream_spock->data + offset, spock->nombre, strlen(spock->nombre) + 1); offset += strlen(spock->nombre) + 1; t_stream* stream_mascota = mascota_serialize(spock->mascota); stream_spock->data = realloc(stream_spock->data, stream_spock->size + stream_mascota->size); memcpy(stream_spock->data + offset, stream_mascota->data, stream_mascota->size); stream_spock->size += stream_mascota->size; offset += stream_mascota->size; stream_destroy(stream_mascota); t_stream* stream_mision = mision_serialize(spock->mision); stream_spock->data = realloc(stream_spock->data, stream_spock->size + stream_mision->size); memcpy(stream_spock->data + offset, stream_mision->data, stream_mision->size); stream_spock->size += stream_mision->size; offset += stream_mision->size; stream_destroy(stream_mision); void serialize_element_villano(void* element) { t_villano* villano = element; t_stream* stream_villano = villano_serialize(villano); stream_spock->data = realloc(stream_spock->data, stream_spock->size + stream_villano->size); memcpy(stream_spock->data + offset, stream_villano->data, stream_villano->size); stream_spock->size += stream_villano->size; offset += stream_villano->size; stream_destroy(stream_villano); }
static void g729_destroy(long h_codec) { struct G729_codec *codec = (struct G729_codec *) h_codec; if (!h_codec) return; stream_destroy(&codec->dec); stream_destroy(&codec->enc); free(codec); }
void cdc_acmd_destroy(CDC_ACMD* cdc_acmd) { io_destroy(cdc_acmd->notify); io_destroy(cdc_acmd->rx); stream_close(cdc_acmd->rx_stream_handle); stream_destroy(cdc_acmd->rx_stream); io_destroy(cdc_acmd->tx); stream_close(cdc_acmd->tx_stream_handle); stream_destroy(cdc_acmd->tx_stream); free(cdc_acmd); }
static void read_test(void *v_t) { struct read_test *t = v_t; enum stream_result sres; ssize_t res; switch (t->step) { case 0: t->stream = delim_read_next(t->dr); t->pos = 0; STEP: res = read_some(t, 8); if (res == STREAM_WAITING) return; assert(res == 7); assert(!memcmp(t->buf, "hello, ", 7)); STEP: sres = stream_close(t->stream, &t->tasklet, &t->err); if (sres == STREAM_WAITING) return; assert(sres == STREAM_OK); stream_destroy(t->stream); t->stream = delim_read_next(t->dr); t->pos = 0; STEP: res = read_some(t, 7); if (res == STREAM_WAITING) return; assert(res == 6); assert(!memcmp(t->buf, "world!", 6)); STEP: sres = stream_close(t->stream, &t->tasklet, &t->err); if (sres == STREAM_WAITING) return; assert(sres == STREAM_OK); stream_destroy(t->stream); } tasklet_stop(&t->tasklet); application_stop(); }
static void send(void *v_s) { struct sender *s = v_s; if (!s->output) { s->output = async_transport_send(s->transport, s->address, &s->err); assert(s->output); } for (;;) { switch (stream_write_bytes(s->output, &s->buf, &s->tasklet, &s->err)) { case STREAM_ERROR: die("%s", error_message(&s->err)); /* fall through */ case STREAM_END: stream_destroy(s->output); s->output = NULL; tasklet_stop(&s->tasklet); /* fall through */ case STREAM_WAITING: return; } } }
int knet_channel_ref_destroy(kchannel_ref_t* channel_ref) { verify(channel_ref); if (channel_ref->ref_info) { /* 检测引用计数 */ if (!atomic_counter_zero(&channel_ref->ref_info->ref_count)) { return error_ref_nonzero; } if (channel_ref->ref_info->peer_address) { knet_address_destroy(channel_ref->ref_info->peer_address); } if (channel_ref->ref_info->local_address) { knet_address_destroy(channel_ref->ref_info->local_address); } /* 通知选取器删除管道相关资源 */ if ((channel_ref->ref_info->state != channel_state_init) && /* 已经被加入到loop管道链表 */ channel_ref->ref_info->loop) { knet_impl_remove_channel_ref(channel_ref->ref_info->loop, channel_ref); } if (channel_ref->ref_info->channel) { knet_channel_destroy(channel_ref->ref_info->channel); } if (channel_ref->ref_info->stream) { stream_destroy(channel_ref->ref_info->stream); } destroy(channel_ref->ref_info); } destroy(channel_ref); return error_ok; }
void bitclient_generateTxHash(uint32 nonce1, uint32 userExtraNonceLength, uint8* userExtraNonce, uint32 coinBase1Length, uint8* coinBase1, uint32 coinBase2Length, uint8* coinBase2, uint8* txHash) { stream_t* streamTXData = streamEx_fromDynamicMemoryRange(1024*32); stream_writeData(streamTXData, coinBase1, coinBase1Length); stream_writeData(streamTXData, &nonce1, 4); stream_writeData(streamTXData, userExtraNonce, userExtraNonceLength); stream_writeData(streamTXData, coinBase2, coinBase2Length); sint32 transactionDataLength = 0; uint8* transactionData = (uint8*)streamEx_map(streamTXData, &transactionDataLength); // special case, we can use the hash of the transaction #if 0 int i; printf("Merkle:\n"); for(i=0; i < transactionDataLength; i++){ printf("%2.2x ", transactionData[i]); } printf("\n"); #endif uint8 hashOut[32]; sha256_context sctx; sha256_starts(&sctx); sha256_update(&sctx, transactionData, transactionDataLength); sha256_finish(&sctx, hashOut); sha256_starts(&sctx); sha256_update(&sctx, hashOut, 32); sha256_finish(&sctx, txHash); free(transactionData); stream_destroy(streamTXData); }
/** * context: {} * tokens : {} * options: {--output=FILE} */ static int cli_bgp_topology_dump(cli_ctx_t * ctx, cli_cmd_t * cmd) { gds_stream_t * stream= gdsout; const char * arg; int result; arg= cli_get_opt_value(cmd, "output"); if (arg != NULL) { stream= stream_create_file(arg); if (stream == NULL) { cli_set_user_error(cli_get(), "unable to create \"%s\"", arg); return CLI_ERROR_COMMAND_FAILED; } } // result= aslevel_topo_dump_stubs(stream); result= aslevel_topo_dump(stream); if (stream != gdsout) stream_destroy(&stream); if (result != ASLEVEL_SUCCESS) { cli_set_user_error(cli_get(), "could not dump topology (%s)", aslevel_strerror(result)); return CLI_ERROR_COMMAND_FAILED; } return CLI_SUCCESS; }
bool bbruntime_destroy(){ runtime_glfw3_destroy(); graphics_destroy(); blitz2d_destroy(); pixmap_destroy(); userlibs_destroy(); audio_fmod_destroy(); audio_destroy(); input_directinput8_destroy(); input_destroy(); timer_windows_destroy(); filesystem_windows_destroy(); filesystem_destroy(); system_windows_destroy(); bank_destroy(); system_destroy(); runtime_destroy(); enet_destroy(); sockets_destroy(); stream_destroy(); stdio_destroy(); string_destroy(); math_destroy(); event_destroy(); hook_destroy(); blitz_destroy(); return true; }
/** * context: {} * tokens : {} * options: {--output=FILE} */ static int cli_bgp_topology_stat(cli_ctx_t * ctx, cli_cmd_t * cmd) { gds_stream_t * stream= gdsout; as_level_topo_t * topo= aslevel_get_topo(); const char * arg; if (topo == NULL) { cli_set_user_error(cli_get(), "no topology loaded"); return CLI_ERROR_COMMAND_FAILED; } arg= cli_get_opt_value(cmd, "output"); if (arg != NULL) { stream= stream_create_file(arg); if (stream == NULL) { cli_set_user_error(cli_get(), "unable to create \"%s\"", arg); return CLI_ERROR_COMMAND_FAILED; } } aslevel_stat_degree(stream, topo, 1, 1, 1); if (stream != gdsout) stream_destroy(&stream); return CLI_SUCCESS; }
/** * context: {router, peer} * tokens: {file|-} */ static int cli_peer_record(cli_ctx_t * ctx, cli_cmd_t * cmd) { bgp_peer_t * peer= _peer_from_context(ctx); const char * arg= cli_get_arg_value(cmd, 0); gds_stream_t * stream; /* Get filename */ if (strcmp(arg, "-") == 0) { bgp_peer_set_record_stream(peer, NULL); } else { stream= stream_create_file(arg); if (stream == NULL) { cli_set_user_error(cli_get(), "could not open \"%s\" for writing", arg); return CLI_ERROR_COMMAND_FAILED; } if (bgp_peer_set_record_stream(peer, stream) < 0) { stream_destroy(&stream); cli_set_user_error(cli_get(), "could not set the peer record stream"); return CLI_ERROR_COMMAND_FAILED; } } return CLI_SUCCESS; }
int main( int argc, char *argv[] ) { int ind; stream_t *cur; // Show the stream filter on stdout stream_show( streams ); // Create the stream filter stream_create( streams ); // Fill the input buffer of the required nodes for( cur = &streams[0]; cur->node.name != NULL; cur++ ) { if( cur->start ) fill_buffer( cur->node.input ); } // Run the output thread ind = (sizeof(streams) / sizeof(stream_t)) - 2; streams[ind].node.func( &streams[ind].node ); // Wait for the stream filter to finish and then clean it up stream_destroy( streams ); // Exit the program return 0; }
static void write_test(void *v_t) { struct write_test *t = v_t; enum stream_result sres; switch (t->step) { case 0: t->stream = delim_write_next(t->dw); t->pos = 0; STEP: sres = write_some(t, "hello, ", 7); if (sres == STREAM_WAITING) return; assert(sres == STREAM_OK); STEP: sres = stream_close(t->stream, &t->tasklet, &t->err); if (sres == STREAM_WAITING) return; assert(sres == STREAM_OK); stream_destroy(t->stream); t->stream = delim_write_next(t->dw); t->pos = 0; STEP: sres = write_some(t, "world!", 6); if (sres == STREAM_WAITING) return; assert(sres == STREAM_OK); STEP: sres = stream_close(t->stream, &t->tasklet, &t->err); if (sres == STREAM_WAITING) return; assert(sres == STREAM_OK); stream_destroy(t->stream); } tasklet_stop(&t->tasklet); application_stop(); }
void article_destroy(article_t* article) { stream_destroy(&article->stream); array_free(article->stack); array_free(article->words); array_free(article->sentences); }
void article_reset(article_t* article) { stream_destroy(&article->stream); array_reset(article->stack); array_reset(article->words); array_reset(article->sentences); article->num_words = 0; }
void dyad_shutdown(void) { /* Close and destroy all the streams */ while (dyad_streams) { dyad_close(dyad_streams); stream_destroy(dyad_streams); } /* Clear up everything */ select_deinit(&dyad_selectSet); #ifdef _WIN32 WSACleanup(); #endif }
static void destroyClosedStreams(void) { dyad_Stream *stream = dyad_streams; while (stream) { if (stream->state == DYAD_STATE_CLOSED) { dyad_Stream *next = stream->next; stream_destroy(stream); stream = next; } else { stream = stream->next; } } }
static void sender_fini(struct sender *s) { mutex_lock(&s->mutex); if (s->output) stream_destroy(s->output); error_fini(&s->err); tasklet_fini(&s->tasklet); mutex_unlock_fini(&s->mutex); address_release(s->address); }
static void _set_log_progress(sched_t * self, const char * filename) { sched_static_t * sched= (sched_static_t *) self; if (sched->pProgressLogStream != NULL) stream_destroy(&sched->pProgressLogStream); if (filename != NULL) { sched->pProgressLogStream= stream_create_file(filename); stream_printf(sched->pProgressLogStream, "# C-BGP Queue Progress\n"); stream_printf(sched->pProgressLogStream, "# <step> <time (us)> <depth>\n"); } }
void lang_destroy(lang_t* lang) { stream_destroy(&lang->stream); array_free(lang->pre1); array_free(lang->post1); array_free(lang->manual); array_free(lang->synonyms); array_free(lang->pre); array_free(lang->post); array_free(lang->line_break); array_free(lang->line_dont_break); array_free(lang->exclude); }
gboolean jabber_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data){ if (stop_it && stream){ if (stop_it>1){ stream_destroy(stream); stream=NULL; g_main_quit(main_loop); } stop_it++; } else if (stream==NULL) g_main_quit(main_loop); return TRUE; }
int jabber_done(){ if (stream){ stream_destroy(stream); stream=NULL; } if (jabber_source){ g_source_destroy(jabber_source); } g_free(register_instructions); g_free(search_instructions); g_free(gateway_desc); g_free(gateway_prompt); stream_del_destroy_handler(jabber_stream_destroyed); return 0; }
void logon () { int len; char *sn = PARAM_SCREEN_NAME; char *pass; char login[11]; stream_t stream; u_int16_t streamid = htons(0x16); log (LOG_NOTICE, _("Loging into provider as '%s'\n"), sn); get_password (sn, &pass); len = strlen (sn); if (len < 10) { strncpy (login, sn, len); memset (&login[len], ' ', 10 - len); sn = login; sn[10]=0; } stream_init(&stream); stream_put(&stream, sizeof(streamid), &streamid); add_atom(&stream, UNI_PID, UNI_START_STREAM, 0); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_RELATIVE, 1); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_INDEX, 5); add_atom(&stream, DE_PID , DE_DATA, sn); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_RELATIVE, 2); add_atom(&stream, DE_PID , DE_DATA, pass); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_RELATIVE, 16); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_INDEX, 1); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, UNI_PID, UNI_END_STREAM, 0); fdo_send (TOKEN ("Dd"), stream.data, stream.used); stream_destroy(&stream); fdo_unregister (TOKEN ("SD")); fdo_register (TOKEN ("At"), login_confirm); fdo_register (TOKEN ("AT"), atom_handler); fdo_register (TOKEN ("at"), atom_handler); }
int main(int argc, char** argv) { int show_usage; printf("Myst IV texture extractor\n"); printf("WRS (XeNTaX.com)\n\n"); show_usage = 1; if (argc > 1) { switch (argv[1][0]) { case 'e': { if (argc == 4) { show_usage = 0; FStream *fs_in; stream_create(&fs_in); if (stream_open(fs_in, argv[2]) == 1) { printf("Failed to open source file\n"); } else { extract_bin_texture(fs_in, argv[3]); } stream_destroy(&fs_in); } break; } } } if (show_usage != 0) { printf("Usage:\n"); printf(" myst_extract_img e <file>.bin <result>\n"); printf("\n"); } mem_dbg(); return 0; }
apr_status_t h2_mplx_cleanup_stream(h2_mplx *m, h2_stream *stream) { AP_DEBUG_ASSERT(m); apr_status_t status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get(m->stream_ios, stream->id); if (!io || io->task_done) { /* No more io or task already done -> cleanup immediately */ stream_destroy(m, stream, io); } else { /* Add stream to closed set for cleanup when task is done */ h2_stream_set_add(m->closed, stream); } apr_thread_mutex_unlock(m->lock); } return status; }
long g729_create(const char* format_parameters, const char** format_parameters_out, amci_codec_fmt_info_t** format_description) { USC_CodecInfo pInfo; struct G729_codec *codec; if (USC_NoError != fns->std.GetInfo((USC_Handle)NULL, &pInfo)) { ERROR("g729: Can't query codec info\n"); return (0); } pInfo.params.direction = 0; /* Direction: encode */ pInfo.params.modes.vad = 0; /* Suppress a silence compression */ pInfo.params.law = 0; /* Linear PCM input */ pInfo.params.modes.bitrate = 8000; /* pInfo.pRateTbl[pInfo.nRates-1].bitrate; */ /* Set highest bitrate */ codec = calloc(sizeof(struct G729_codec), 1); if (stream_create(&pInfo, &codec->enc, "encoder")) { free(codec); return 0; } pInfo.params.direction = 1; /* Direction: decode */ if (stream_create(&pInfo, &codec->dec, "decoder")) { stream_destroy(&codec->enc); free(codec); return 0; } codec->pInfo = pInfo; *format_description = g729_fmt_description; return (long) codec; }
/** * context: {} * tokens : {prefix} * options: {--output=FILE,--exact-match,--preserve-dups} */ static int cli_bgp_topology_recordroute(cli_ctx_t * ctx, cli_cmd_t * cmd) { ip_pfx_t prefix; gds_stream_t * stream= gdsout; const char * arg= cli_get_arg_value(cmd, 0); int result; uint8_t options= 0; // Destination prefix if (str2prefix(arg, &prefix) < 0) { cli_set_user_error(cli_get(), "invalid prefix \"%s\"", arg); return CLI_ERROR_COMMAND_FAILED; } // Optional output file ? arg= cli_get_opt_value(cmd, "output"); if (arg != NULL) { stream= stream_create_file(arg); if (stream == NULL) { cli_set_user_error(cli_get(), "unable to create \"%s\"", arg); return CLI_ERROR_COMMAND_FAILED; } } if (cli_has_opt_value(cmd, "exact-match")) options|= AS_RECORD_ROUTE_OPT_EXACT_MATCH; if (cli_has_opt_value(cmd, "preserve-dups")) options|= AS_RECORD_ROUTE_OPT_PRESERVE_DUPS; // Record routes result= aslevel_topo_record_route(stream, prefix, options); if (result != ASLEVEL_SUCCESS) { cli_set_user_error(cli_get(), "could not record route (%s)", aslevel_strerror(result)); return CLI_ERROR_COMMAND_FAILED; } if (stream != gdsout) stream_destroy(&stream); return CLI_SUCCESS; }
void bitclient_generateTxHash(uint32 userExtraNonceLength, uint8* userExtraNonce, uint32 coinBase1Length, uint8* coinBase1, uint32 coinBase2Length, uint8* coinBase2, uint8* txHash) { stream_t* streamTXData = streamEx_fromDynamicMemoryRange(1024*32); stream_writeData(streamTXData, coinBase1, coinBase1Length); stream_writeData(streamTXData, userExtraNonce, userExtraNonceLength); stream_writeData(streamTXData, coinBase2, coinBase2Length); sint32 transactionDataLength = 0; uint8* transactionData = (uint8*)streamEx_map(streamTXData, &transactionDataLength); // special case, we can use the hash of the transaction uint8 hashOut[32]; sha256_ctx sctx; sha256_init(&sctx); sha256_update(&sctx, transactionData, transactionDataLength); sha256_final(&sctx, hashOut); sha256_init(&sctx); sha256_update(&sctx, hashOut, 32); sha256_final(&sctx, txHash); free(transactionData); stream_destroy(streamTXData); }
// -----[ _destroy ]------------------------------------------------- static void _destroy(sched_t ** sched_ref) { sched_static_t * sched; if (*sched_ref != NULL) { sched= (sched_static_t *) *sched_ref; // Free private part if (sched->events->current_depth > 0) cbgp_warn("%d event%s still in simulation queue.\n", sched->events->current_depth, (sched->events->current_depth>1?"s":"")); fifo_destroy(&sched->events); if (sched->pProgressLogStream != NULL) stream_destroy(&sched->pProgressLogStream); FREE(sched); *sched_ref= NULL; } }