static void do_free(void) { TRY(ef_vi_filter_del(&vi, driver_handle, &filter_cookie)); TRY(ef_vi_flush(&vi, driver_handle)); TRY(ef_memreg_free(&memreg, driver_handle)); free(pkt_buf_mem); TRY(ef_vi_free(&vi, driver_handle)); TRY(ef_pd_free(&pd, driver_handle)); TRY(ef_driver_close(driver_handle)); }
static status computeLabel(Label lb) { if ( notNil(lb->request_compute) ) { int w, h, b; TRY(obtainClassVariablesObject(lb)); b = valInt(lb->border); if ( notNil(lb->elevation) ) b += abs(valInt(lb->elevation->height)); if ( instanceOfObject(lb->selection, ClassCharArray) ) { String s = &((CharArray)lb->selection)->data; int minw; int ex = valInt(getExFont(lb->font)); if ( lb->wrap == NAME_clip ) { LocalString(buf, s->iswide, s->size+1); str_one_line(buf, s); s = buf; } str_size(s, lb->font, &w, &h); w += ex; if ( notDefault(lb->width) ) minw = valInt(lb->width) - 2*b; else minw = (valInt(lb->length)+1) * ex; w = max(w, minw); } else /*if ( instanceOfObject(lb->selection, ClassImage) )*/ { Image image = (Image) lb->selection; w = valInt(image->size->w); h = valInt(image->size->h); } w += 2*b; h += 2*b; CHANGING_GRAPHICAL(lb, assign(lb->area, w, toInt(w)); assign(lb->area, h, toInt(h)); changedEntireImageGraphical(lb)); assign(lb, request_compute, NIL); }
void TestExceptionsSupport() { REMARK (__FUNCTION__); size_t test_vector[NUMBER_OF_ELEMENTS + 1]; for (size_t i = 0; i < NUMBER_OF_ELEMENTS; i++) { test_vector[i] = i; } Iterator begin(&test_vector[0]); Iterator end(&test_vector[NUMBER_OF_ELEMENTS]); TRY(); tbb::parallel_for_each(begin, end, (TestFunctionType)test_function_with_exception); CATCH_AND_ASSERT(); }
/* Option: --proto udp (default), also --port nnn (default 9000) */ static int add_udp(struct configuration* cfg) { int s; struct sockaddr_in host_address; make_address(cfg->cfg_host, cfg->cfg_port, &host_address); s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); TEST(s >= 0); TRY(bind(s, (struct sockaddr*)&host_address, sizeof(host_address)) ); printf("UDP socket created, listening on port %d\n", cfg->cfg_port); return s; }
error_t Utils:: GetBounded(char const * & input, char const * & output, char start, char end, size_t * len) { Utils::SkipWhitespace(input); if (*input++ != start) return ERROR_EXPECTED_A_GOT_B_1; Utils::SkipWhitespace(input); output = input; char const * ep = input; cell ch; int depth = 1; size_t posLen = 0, truLen = 0; while (*input) { if (*input == end) { if (--depth == 0) break; ep = ++input; truLen = ++posLen; } else if ((unsigned char)*input > ' ') { // Allow nested start/end pairs. Note that if "start" and "end" are // the same, then the earlier branch will have been hit already. if (*input == start) ++depth, ++input; else TRY(Utils::ReadChar(input, ch)); ep = input; truLen = ++posLen; } else { ++input; ++posLen; } } if (*input != end) return ERROR_EXPECTED_A_GOT_B_2; *const_cast<char *>(ep) = '\0'; if (len) *len = truLen; ++input; Utils::SkipWhitespace(input); return OK; }
static status computeButton(Button b) { if ( notNil(b->request_compute) ) { int w, h, isimage; TRY(obtainClassVariablesObject(b)); dia_label_size(b, &w, &h, &isimage); if ( b->look == NAME_winMenuBar || b->look == NAME_gtkMenuBar ) { if ( !isimage ) { w += valInt(getExFont(b->label_font)) * 2; if ( b->look == NAME_gtkMenuBar ) h += 4; } else { w += 4; h += 4; } } else { if ( isimage ) { w += 4; h += 4; } else { Size size = getClassVariableValueObject(b, NAME_size); h += 6; w += 10 + valInt(b->radius); if ( notNil(b->popup) ) { if ( notNil(b->popup->popup_image) ) w += valInt(b->popup->popup_image->size->w) + 5; else if ( b->look == NAME_motif || b->look == NAME_gtk ) w += 12 + 5; else w += 9 + 5; } w = max(valInt(size->w), w); h = max(valInt(size->h), h); } } CHANGING_GRAPHICAL(b, assign(b->area, w, toInt(w)); assign(b->area, h, toInt(h))); assign(b, request_compute, NIL); }
void FUNC ( LALStatus *status, STYPE **aseq ) { /* * Initialize status */ INITSTATUS(status); ATTATCHSTATUSPTR( status ); /* * Check aseq: is it non-NULL? */ ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR); /* * Check aseq: does it point to non-NULL? */ ASSERT (*aseq != NULL,status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR); /* * Check dimLength in aseq: does it point to non-NULL? */ ASSERT ((*aseq)->dimLength != NULL, status, SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR); /* * Check data in aseq: does it point to non-NULL? */ ASSERT ((*aseq)->data != NULL, status, SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR); /* Ok, now let's free allocated storage */ TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ), status ); LALFree ( (*aseq)->data ); /* free allocated data */ LALFree ( *aseq ); /* free aseq struct itself */ *aseq = NULL; /* make sure we don't point to freed struct */ DETATCHSTATUSPTR( status ); RETURN (status); }
Bool HG_(recognised_suppression) ( Char* name, Supp *su ) { # define TRY(_name,_xskind) \ if (0 == VG_(strcmp)(name, (_name))) { \ VG_(set_supp_kind)(su, (_xskind)); \ return True; \ } TRY("Race", XS_Race); TRY("FreeMemLock", XS_FreeMemLock); TRY("UnlockUnlocked", XS_UnlockUnlocked); TRY("UnlockForeign", XS_UnlockForeign); TRY("UnlockBogus", XS_UnlockBogus); TRY("PthAPIerror", XS_PthAPIerror); TRY("LockOrder", XS_LockOrder); TRY("Misc", XS_Misc); return False; # undef TRY }
static s8t decode_USM_parameters(u8t* const input, const u16t input_len, u16t* pos, message_v3_t* request) { u8t type; u16t length; /* encoded as a string value */ TRY(ber_decode_type_length(input, input_len, pos, &type, &length)); if (type != BER_TYPE_OCTET_STRING) { snmp_log("bad type, expected string: type %02X length %d\n", type, length); return FAILURE; } /* sequence */ TRY(ber_decode_sequence_length(input, input_len, pos, &length)); /* msgAuthoritativeEngineID */ TRY(ber_decode_string((u8t*)input, input_len, pos, &request->msgAuthoritativeEngineID.ptr, &request->msgAuthoritativeEngineID.len)); /* msgAuthoritativeEngineBoots */ TRY(ber_decode_integer(input, input_len, pos, (s32t*)&request->msgAuthoritativeEngineBoots)); /* msgAuthoritativeEngineTime */ TRY(ber_decode_integer(input, input_len, pos, (s32t*)&request->msgAuthoritativeEngineTime)); /* msgUserName */ TRY(ber_decode_string((u8t*)input, input_len, pos, &request->msgUserName.ptr, &request->msgUserName.len)); /* msgAuthenticationParameters */ TRY(ber_decode_string((u8t*)input, input_len, pos, &request->msgAuthenticationParameters.ptr, &request->msgAuthenticationParameters.len)); /* msgPrivacyParameters */ TRY(ber_decode_string((u8t*)input, input_len, pos, &request->msgPrivacyParameters.ptr, &request->msgPrivacyParameters.len)); if (request->msgFlags & FLAG_PRIV) { TRY(ber_decode_type_length((u8t*)input, input_len, pos, &type, &length)); if (type != BER_TYPE_OCTET_STRING || length != input_len - *pos) { return FAILURE; } } return 0; }
PRBool XDR(XPTArena *arena, XPTCursor *cursor, struct TestData *str) { TRY("Do32", XPT_Do32(cursor, &str->bit32)); TRY("Do16", XPT_Do16(cursor, &str->bit16)); TRY("Do8", XPT_Do8 (cursor, &str->bit8[0])); TRY("Do8", XPT_Do8 (cursor, &str->bit8[1])); TRY("DoCString", XPT_DoCString(arena, cursor, &str->cstr)); TRY("DoString", XPT_DoString(arena, cursor, &str->str)); return 0; }
s8t processIncomingMsg_USM(u8t* const input, const u16t input_len, u16t* pos, message_v3_t* request) { /* If the value of the msgAuthoritativeEngineID field in the securityParameters is unknown, return usmStatsUnknownEngineIDs */ TRY(decode_USM_parameters(input, input_len, pos, request)); if (request->msgAuthoritativeEngineID.len != getEngineID()->len || memcmp(request->msgAuthoritativeEngineID.ptr, getEngineID()->ptr, getEngineID()->len)) { TRY(report(request, &usmStatsUnknownEngineIDs, &usmStatsUnknownEngineIDCounter)); return ERR_USM; } /* check user name */ if (request->msgUserName.len != strlen((char*)getUserName()) || memcmp(request->msgUserName.ptr, getUserName(), request->msgUserName.len) != 0) { TRY(report(request, &usmStatsUnknownUserNames, &usmStatsUnknownUserNamesCounter)); return ERR_USM; } if (request->msgFlags & FLAG_AUTH) { #if ENABLE_AUTH /* The timeliness check is only performed if authentication is applied to the message */ if (request->msgAuthenticationParameters.len != 12 || isBadHMAC(input, input_len, request) != ERR_NO_ERROR) { TRY(report(request, &usmStatsWrongDigests, &usmStatsWrongDigestsCounter)); return ERR_USM; } #else return FAILURE; #endif } if (request->msgAuthoritativeEngineBoots != getMsgAuthoritativeEngineBoots() || abs(request->msgAuthoritativeEngineTime - getSysUpTime()) < TIME_WINDOW) { TRY(report(request, &usmStatsNotInTimeWindows, &usmStatsNotInTimeWindowsCounter)); return ERR_USM; } if (request->msgFlags & FLAG_PRIV) { #if ENABLE_PRIVACY if (request->msgPrivacyParameters.len != 8) { TRY(report(request, &usmStatsDecryptionErrors, &usmStatsDecryptionErrorsCounter)); return ERR_USM; } /* init IV */ u8t iv[16]; convert_2_octets(iv, request->msgAuthoritativeEngineBoots); convert_2_octets(iv + 4, request->msgAuthoritativeEngineTime); memcpy(iv + 8, request->msgPrivacyParameters.ptr, 8); /* decode the Scoped PDU */ aes_process(getPrivKul(), iv, input + *pos, input + *pos, input_len - *pos, AES_DECRYPT); #else return FAILURE; #endif } return 0; }
int main(void) { plan_tests(9); MEMREF act, x = strref("hello, world"); # define S(s) ((s) ? (s) : "(null)") # define TRY(p, l, exp) \ if (!ok(!refcmp(act = subref(x,p,l), strref(exp)), "(%d, %d): %s", p, l, S(exp))) \ fprintf(stderr, "act[%"FSIZE"d]: %.*s\n", act.len, (int)act.len, S(act.ptr)) TRY( 0, 5, "hello"); TRY( 2, 3, "llo"); TRY( -5, 2, "wo"); TRY( -5, 99, "world"); TRY(-12, 2, "he"); TRY( 0, -1, x.ptr); // (len) is unsigned, so (-1) is just a very big positive number. TRY( 0, 0, NULL); TRY( 1, 0, NULL); TRY(-13, 2, NULL); return exit_status(); }
h5_err_t h5t_map_global_vertex_indices2local ( h5t_mesh_t* const m, const h5_glb_idx_t* const glb_indices, const h5_size_t size, h5_loc_idx_t* const loc_indices ) { H5_CORE_API_ENTER (h5_err_t, "m=%p, glb_indices=%p, size=%llu, loc_indices=%p", m, glb_indices, (long long unsigned)size, loc_indices); h5_size_t i; for (i = 0; i < size; i++) { TRY (loc_indices[i] = h5t_map_global_vertex_idx2local (m, glb_indices[i])); } H5_CORE_API_RETURN (H5_SUCCESS); }
void NationalInstrumentsDAQ::setupAOChannels( float64 nrecords, float64 record_frequency_Hz, float64 vmin, float64 vmax, IDAQPhysicalChannel **channels, int nchannels ) { TaskHandle ao = 0; int32 N = _config->ao_samples_per_waveform(); char terms[MAX_CHAN_STRING]= {0}; const char *dev = _config->name().c_str(), *trig = _config->trigger().c_str(); char clk[MAX_CHAN_STRING] = {0}; float64 hz = computeSampleFrequency(nrecords,record_frequency_Hz), lvl = _config->level_volts(); strcat(clk,_config->ctr().c_str()); strcat(clk,"InternalOutput"); // terminal names TRY(nchannels<countof(terms)); { const char* names[8]={0}; for(int i=0;i<nchannels;++i) names[i]=channels[i]->name(); cat_terminal_names(terms,sizeof(terms),dev,names,nchannels); } // voltage range { f64 v[4]; DAQERR(DAQmxGetDevAOVoltageRngs(_config->name().c_str(),v,4)); vmin = MAX(vmin,v[2]); vmax = MIN(vmax,v[3]); } ao=_ao.daqtask; DAQERR(DAQmxCreateAOVoltageChan (ao,terms,NULL,vmin,vmax,DAQmx_Val_Volts,NULL)); DAQERR(DAQmxCfgSampClkTiming (ao,clk,hz,DAQmx_Val_Rising,DAQmx_Val_ContSamps,N)); DAQERR(DAQmxCfgOutputBuffer (ao,10*N)); DAQERR(DAQmxSetWriteRegenMode (ao,DAQmx_Val_DoNotAllowRegen)); DAQERR(DAQmxSetWriteRelativeTo (ao,DAQmx_Val_CurrWritePos)); DAQERR(DAQmxSetAODataXferMech (ao,terms,DAQmx_Val_DMA)); DAQERR(DAQmxSetAODataXferReqCond(ao,terms,DAQmx_Val_OnBrdMemNotFull)); DAQERR(DAQmxCfgAnlgEdgeStartTrig(ao,trig,DAQmx_Val_Rising,lvl)); return; Error: UNREACHABLE; }
value_t get_or_create_methodspace_selector_slice(runtime_t *runtime, value_t self, value_t selector) { value_t cache_ptr = get_methodspace_cache_ptr(self); value_t cache = get_freeze_cheat_value(cache_ptr); // Create the cache if it doesn't exist. if (is_nothing(cache)) { TRY_SET(cache, new_heap_id_hash_map(runtime, 128)); set_freeze_cheat_value(cache_ptr, cache); } // Create the selector-specific cache if it doesn't exits. value_t slice = get_id_hash_map_at(cache, selector); if (in_condition_cause(ccNotFound, slice)) { TRY_SET(slice, create_methodspace_selector_slice(runtime, self, selector)); TRY(set_id_hash_map_at(runtime, cache, selector, slice)); } return slice; }
static enum v7_err do_logical_op(struct v7 *v7, int op) { struct v7_val **v = v7_top(v7) - 2; if (v7->no_exec) return V7_OK; CHECK(v[0]->type == V7_NUM && v[1]->type == V7_NUM, V7_TYPE_MISMATCH); switch (op) { case OP_GT: v[0]->v.num = v[0]->v.num > v[1]->v.num ? 1.0 : 0.0; break; case OP_GE: v[0]->v.num = v[0]->v.num >= v[1]->v.num ? 1.0 : 0.0; break; case OP_LT: v[0]->v.num = v[0]->v.num < v[1]->v.num ? 1.0 : 0.0; break; case OP_LE: v[0]->v.num = v[0]->v.num <= v[1]->v.num ? 1.0 : 0.0; break; case OP_EQ: v[0]->v.num = v[0]->v.num == v[1]->v.num ? 1.0 : 0.0; break; } TRY(inc_stack(v7, -1)); return V7_OK; }
static int add_socket(struct configuration* cfg) { int s; struct sockaddr_in host_address; int domain = SOCK_DGRAM; if ( cfg->cfg_protocol == IPPROTO_TCP ) domain = SOCK_STREAM; make_address(cfg->cfg_port, &host_address); s = socket(PF_INET, domain, cfg->cfg_protocol); TEST(s >= 0); TRY(bind(s, (struct sockaddr*)&host_address, sizeof(host_address)) ); printf("Socket created, listening on port %d\n", cfg->cfg_port); return s; }
// code = { statement } enum v7_err v7_exec(struct v7 *v7, const char *source_code) { v7->source_code = v7->cursor = source_code; skip_whitespaces_and_comments(v7); // The following code may raise an exception and jump to the previous line, // returning non-zero from the setjmp() call // Prior calls to v7_exec() may have left current_scope modified, reset now v7->current_scope = 0; // XXX free up higher scopes? inc_stack(v7, -v7->sp); while (*v7->cursor != '\0') { inc_stack(v7, -v7->sp); // Reset stack on each statement TRY(parse_statement(v7, 0)); // Leave the result of last expr on stack } return V7_OK; }
errorCode addLnEntry(LnTable* lnTable, String lnStr, Index* lnEntryId) { errorCode tmp_err_code; LnEntry* lnEntry; TRY(addEmptyDynEntry(&lnTable->dynArray, (void**)&lnEntry, lnEntryId)); // Fill in local names entry lnEntry->lnStr = lnStr; lnEntry->elemGrammar = INDEX_MAX; lnEntry->typeGrammar = INDEX_MAX; #if VALUE_CROSSTABLE_USE // The Vx table is created on-demand (additions to value cross table are done when a value is inserted in the value table) lnEntry->vxTable = NULL; #endif return EXIP_OK; }
static status deleteChainTable(ChainTable ct, Any name, Any value) { Chain ch; if ( isDefault(value) ) return deleteHashTable((HashTable)ct, name); if ( (ch = getMemberHashTable((HashTable) ct, name)) ) { TRY(deleteChain(ch, value)); if ( emptyChain(ch) ) deleteHashTable((HashTable) ct, name); succeed; } fail; }
static s8t encode_USM_parameters(message_v3_t* message, u8t* output, u16t buf_len, s16t* pos) { if (message->msgFlags & FLAG_PRIV) { #if ENABLE_PRIVACY u8t iv[16]; /* IV */ convert_2_octets(iv, message->msgAuthoritativeEngineBoots); convert_2_octets(iv + 4, message->msgAuthoritativeEngineTime); /* privace parameters */ convert_2_octets(message->msgPrivacyParameters.ptr, getLPrivacyParameters()); convert_2_octets(message->msgPrivacyParameters.ptr, getHPrivacyParameters()); memcpy(iv + 8, message->msgPrivacyParameters.ptr, 8); aes_process(getPrivKul(), iv, output + *pos, output + *pos, buf_len - *pos, AES_ENCRYPT); TRY(ber_encode_type_length(output, pos, BER_TYPE_OCTET_STRING, buf_len - *pos)); #else return FAILURE; #endif } s16t tmpPos = *pos; TRY(ber_encode_fixed_string(output, pos, message->msgPrivacyParameters.ptr, message->msgPrivacyParameters.len)); TRY(ber_encode_fixed_string(output, pos, message->msgAuthenticationParameters.ptr, message->msgAuthenticationParameters.len)); message->msgAuthenticationParameters.ptr = &output[*pos + 2]; TRY(ber_encode_fixed_string(output, pos, message->msgUserName.ptr, message->msgUserName.len)); TRY(ber_encode_integer(output, pos, BER_TYPE_INTEGER, message->msgAuthoritativeEngineTime)); TRY(ber_encode_integer(output, pos, BER_TYPE_INTEGER, message->msgAuthoritativeEngineBoots)); TRY(ber_encode_fixed_string(output, pos, message->msgAuthoritativeEngineID.ptr, message->msgAuthoritativeEngineID.len)); TRY(ber_encode_type_length(output, pos, BER_TYPE_SEQUENCE, tmpPos - *pos)); TRY(ber_encode_type_length(output, pos, BER_TYPE_OCTET_STRING, tmpPos - *pos)); return 0; }
errorCode initSchema(EXIPSchema* schema, InitSchemaType initializationType) { errorCode tmp_err_code = UNEXPECTED_ERROR; TRY(initAllocList(&schema->memList)); schema->staticGrCount = 0; SET_CONTENT_INDEX(schema->docGrammar.props, 0); schema->docGrammar.count = 0; schema->docGrammar.props = 0; schema->docGrammar.rule = NULL; schema->simpleTypeTable.count = 0; schema->simpleTypeTable.sType = NULL; schema->grammarTable.count = 0; schema->grammarTable.grammar = NULL; schema->enumTable.count = 0; schema->enumTable.enumDef = NULL; /* Create and initialize initial string table entries */ TRY_CATCH(createDynArray(&schema->uriTable.dynArray, sizeof(UriEntry), DEFAULT_URI_ENTRIES_NUMBER), freeAllocList(&schema->memList)); TRY_CATCH(createUriTableEntries(&schema->uriTable, initializationType != INIT_SCHEMA_SCHEMA_LESS_MODE), freeAllocList(&schema->memList)); if(initializationType == INIT_SCHEMA_SCHEMA_ENABLED) { /* Create and initialize enumDef table */ TRY_CATCH(createDynArray(&schema->enumTable.dynArray, sizeof(EnumDefinition), DEFAULT_ENUM_TABLE), freeAllocList(&schema->memList)); } /* Create the schema grammar table */ TRY_CATCH(createDynArray(&schema->grammarTable.dynArray, sizeof(EXIGrammar), DEFAULT_GRAMMAR_TABLE), freeAllocList(&schema->memList)); if(initializationType != INIT_SCHEMA_SCHEMA_LESS_MODE) { /* Create and initialize simple type table */ TRY_CATCH(createDynArray(&schema->simpleTypeTable.dynArray, sizeof(SimpleType), DEFAULT_SIMPLE_GRAMMAR_TABLE), freeAllocList(&schema->memList)); TRY_CATCH(createBuiltInTypesDefinitions(&schema->simpleTypeTable, &schema->memList), freeAllocList(&schema->memList)); // Must be done after createBuiltInTypesDefinitions() TRY_CATCH(generateBuiltInTypesGrammars(schema), freeAllocList(&schema->memList)); schema->staticGrCount = SIMPLE_TYPE_COUNT; } return tmp_err_code; }
void net_if_map_vi_pool(struct net_if* net_if, struct vi* vi) { struct pkt_buf* pkt_buf; ef_memreg memreg; int i; /* If this fails it means you've tried to map buffers into a protection * domain that has already mapped those buffers. */ TEST(vi->net_if != net_if); TRY(ef_memreg_alloc(&memreg, net_if->dh, &net_if->pd, net_if->dh, vi->pkt_bufs, vi->pkt_bufs_n * PKT_BUF_SIZE)); for( i = 0; i < vi->pkt_bufs_n; ++i ) { pkt_buf = pkt_buf_from_id(vi, i); pkt_buf->addr[net_if->id] = ef_memreg_dma_addr(&memreg, i * PKT_BUF_SIZE); } }
error_t Utils:: CopyString(cell * dest, char const * src, size_t len, bool pad) { FAIL(len, ERROR_MEMORY_ALLOCATION_FAIL); while (--len && *src) { TRY(Utils::ReadChar(src, *dest)); ++dest; } // Always has one character reserved for "NULL". *dest++ = '\0'; if (pad) { while (len--) *dest++ = '\0'; } return OK; };
static status loadVector(Vector v, IOSTREAM *fd, ClassDef def) { int n; Any obj; int size; loadSlotsObject(v, fd, def); size = valInt(v->size); v->allocated = v->size; v->elements = alloc(size * sizeof(Any)); for(n = 0; n < size; n++) { TRY( obj = loadObject(fd) ); v->elements[n] = NIL; assignVector(v, n, obj); } succeed; }
/* This is the THIRD function to call for completely initializing the emulation engine. */ int ti68k_init(void) { // init libs ticables_library_init(); tifiles_library_init(); ticalcs_library_init(); // check if image has been loaded if(img_loaded == 0) return ERR_NO_IMAGE; // set calc type and init hardware memset(&tihw, 0, sizeof(Ti68kHardware)); tihw.calc_type = img_infos.calc_type; TRY(hw_init()); return 0; }
static value_t create_methodspace_selector_slice(runtime_t *runtime, value_t self, value_t selector) { TRY_DEF(result, new_heap_signature_map(runtime)); value_t current = self; while (!is_nothing(current)) { value_t methods = get_methodspace_methods(current); value_t entries = get_signature_map_entries(methods); for (int64_t i = 0; i < get_pair_array_buffer_length(entries); i++) { value_t signature = get_pair_array_buffer_first_at(entries, i); if (can_match_eq(signature, ROOT(runtime, selector_key), selector)) { value_t method = get_pair_array_buffer_second_at(entries, i); TRY(add_to_signature_map(runtime, result, signature, method)); } } current = get_methodspace_parent(current); } return result; }
V7_PRIVATE enum v7_err v7_set2(struct v7 *v7, struct v7_val *obj, struct v7_val *k, struct v7_val *v) { struct v7_prop *m = NULL; CHECK(obj != NULL && k != NULL && v != NULL, V7_INTERNAL_ERROR); CHECK(obj->type == V7_TYPE_OBJ, V7_TYPE_ERROR); // Find attribute inside object if ((m = v7_get2(obj, k, 1)) != NULL) { v7_freeval(v7, m->val); inc_ref_count(v); m->val = v; } else { TRY(vinsert(v7, &obj->props, k, v)); } return V7_OK; }
AlError algl_texture_init(AlGlTexture **result) { BEGIN() AlGlTexture *texture = NULL; TRY(al_malloc(&texture, sizeof(AlGlTexture))); texture->id = 0; glGenTextures(1, &texture->id); if (texture->id == 0) { THROW(AL_ERROR_GENERIC) } *result = texture; CATCH( algl_texture_free(texture); )
sparkey_returncode sparkey_logreader_open(sparkey_logreader **log_ref, const char *filename) { RETHROW(correct_endian_platform()); sparkey_logreader *log = malloc(sizeof(sparkey_logreader)); if (log == NULL) { return SPARKEY_INTERNAL_ERROR; } sparkey_returncode returncode; TRY(sparkey_logreader_open_noalloc(log, filename), cleanup); *log_ref = log; return SPARKEY_SUCCESS; cleanup: free(log); return returncode; }