这篇教程C++ BAIL函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BAIL函数的典型用法代码示例。如果您正苦于以下问题:C++ BAIL函数的具体用法?C++ BAIL怎么用?C++ BAIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BAIL函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: FskFSFileRenameFskErr FskFSFileRename(const char *fullPath, const char *newName){ int err; char *p, newPath[PATH_MAX]; FskFileInfo itemInfo; err = sCheckFullPath(fullPath, kFskPathIsFile); BAIL_IF_ERR(err); err = FskFSFileGetFileInfo(fullPath, &itemInfo); BAIL_IF_ERR(err); if (itemInfo.filetype == kFskDirectoryItemIsDirectory) BAIL(kFskErrIsDirectory); p = FskStrRChr((char *)newName, '/'); if (p) BAIL(kFskErrOperationFailed); // newName contains path elements FskStrCopy(newPath, fullPath); p = FskStrRChr(newPath, '/'); if (p) *++p = '/0'; FskStrCat(newPath, newName); err = rename(fullPath, newPath); if (err == -1) BAIL(errnoToFskErr(errno)); err = kFskErrNone;bail: return err;}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:34,
示例2: pam5_basepair_handle_matchstatic voidpam5_basepair_handle_match(struct patternMatch *match){ struct atom *aAh = match->p->atoms[match->atomIndices[0]]; struct atom *aGv = match->p->atoms[match->atomIndices[1]]; struct atom *aS1 = match->p->atoms[match->atomIndices[2]]; struct atom *aS2 = match->p->atoms[match->atomIndices[3]]; struct atom *vA; struct bond *bond; pam5_requires_gromacs(match->p); BAIL(); init_stack_match(); BAIL(); // S1 // | // Gv----Ah // | // S2 if (aAh->isGrounded) { vA = makeVirtualAtom(vAh5_type, sp3, 3, 1, aGv, aS1, aS2, NULL, axis_pq, axis_pq, 0.0); bond = makeBond(match->p, vA, aAh, '1'); queueAtom(match->p, vA); trace_makeVirtualAtom(match, vA); queueBond(match->p, bond); trace_makeBond(match, bond); } //printMatch(match);}
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:33,
示例3: evaluateGradientvoidevaluateGradient(struct configuration *p){ struct functionDefinition *fd; int i; double gradientCoordinate; NULLPTR(p); fd = p->functionDefinition; NULLPTR(fd); if (p->gradient == NULL) { p->gradient = (double *)allocate(sizeof(double) * fd->dimension); if (fd->dfunc == NULL) { evaluateGradientFromPotential(p); BAIL(); } else { (*fd->dfunc)(p); BAIL(); } fd->gradientEvaluationCount++; p->parameter = 0.0; p->maximumCoordinateInGradient = 0.0; for (i=fd->dimension-1; i>=0; i--) { CHECKNAN(p->gradient[i]); gradientCoordinate = fabs(p->gradient[i]); if (p->maximumCoordinateInGradient < gradientCoordinate) { p->maximumCoordinateInGradient = gradientCoordinate; } } }}
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:29,
示例4: alloc_monitoring_datasint alloc_monitoring_datas() { int error = 0; if (world.config == NULL) { goto cleanup; } qsort(world.stored_data, MAX_ACTIVE_ADDRS, sizeof(monitoring_data*), sub_storeptrs); int data_pos = 0; for(int i = 0; i < world.num_active_addrs; i++) { uint8_t addr = world.active_addrs[i]; while(world.stored_data[data_pos] != NULL && world.stored_data[data_pos]->addr != addr) { data_pos++; } if (world.stored_data[data_pos] == NULL) { log("Detected PSU at address 0x%02x/n", addr); //syslog(LOG_INFO, "Detected PSU at address 0x%02x", addr); world.stored_data[data_pos] = alloc_monitoring_data(addr); if (world.stored_data[data_pos] == NULL) { BAIL("allocation failed/n"); } //reset search pos after alloc (post-sorted addrs may already be alloc'd, need to check again) data_pos = 0; continue; } if (world.stored_data[data_pos]->addr == addr) { continue; } BAIL("shouldn't get here!/n"); }cleanup: return error;}
开发者ID:armedTiger,项目名称:openbmc,代码行数:33,
示例5: pam5_phosphate_sugar_match// Sets the phosphate-sugar bond type differently based on the bond// direction. This allows the phosphate to be closer to one sugar// than the other, based on the strand direction.static voidpam5_phosphate_sugar_match(struct patternMatch *match){ struct part *p = match->p; struct atom *aPl = p->atoms[match->atomIndices[0]]; struct atom *aSs = p->atoms[match->atomIndices[1]]; struct bond *b = getBond(p, aPl, aSs); BAIL(); struct stretch *s = getStretch(p, aPl, aSs); BAIL(); int reverse; pam5_requires_gromacs(match->p); BAIL(); init_stack_match(); BAIL(); switch (b->direction) { case 'F': reverse = (b->a1 == aSs); break; case 'R': reverse = (b->a1 == aPl); break; default: ERROR2("pam5_phosphate_sugar_match: bond between ids %d and %d has no direction", aPl->atomID, aSs->atomID); p->parseError(p->stream); return; } s->stretchType = reverse ? stretch_5_Ss_Pl_3 : stretch_5_Pl_Ss_3 ; trace_setStretchType(match, s); //printMatch(match);}
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:36,
示例6: FskFSFileOpen// ---------------------------------------------------------------------FskErr FskFSFileOpen(const char *fullPath, UInt32 permissions, FskFSFile *frefOut) { FskErr err; FskFSFile fref; FskFileInfo itemInfo; if (frefOut) *frefOut = NULL; err = sCheckFullPath(fullPath, kFskPathIsFile); BAIL_IF_ERR(err); err = FskFSFileGetFileInfo(fullPath, &itemInfo); BAIL_IF_ERR(err); if (itemInfo.filetype == kFskDirectoryItemIsDirectory) BAIL(kFskErrIsDirectory); err = FskMemPtrNewClear(sizeof(FskFSFileRecord), (FskMemPtr*)(void*)&fref); BAIL_IF_NONZERO(err, err, kFskErrMemFull); fref->thePermissions = permissions; fref->theFile = FOPEN(fullPath, sPermsToPermStr(permissions)); if (!fref->theFile) { FskMemPtrDispose(fref); BAIL(errnoToFskErr(errno)); } *frefOut = fref; bail: return err;}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:34,
示例7: dircopyint dircopy(char *base, char *src[], int nsrc){ char *dest = NULL; int baselen = strlen(base) + 1; /* +1 for '/' */ int i, destlen = 0, ret = 0;#define BAIL() do{ ret = 1; goto bail; } while(0) for(i = 0; i < nsrc; i++){ int newlen = baselen + strlen(src[i]) + 1; if(destlen < newlen){ char *tmp = realloc(dest, newlen); if(!tmp){ perrorf("realloc()"); BAIL(); } dest = tmp; } if(*src[i] != '/') sprintf(dest, "%s/%s", base, src[i]); else strcpy(dest, src[i]); if(copy(dest, src[i])) BAIL(); }bail: free(dest); return ret;}
开发者ID:bobrippling,项目名称:cbin,代码行数:33,
示例8: nccf_append_att/* Append string to a named global attribute. Create the attribute if * it doesn't exist. */static intnccf_append_att(int ncid, const char *name, const char *string){ char *att_str = NULL; size_t len, new_len; int ret; /* Find out if there is an attribute of this name. */ ret = nc_inq_attlen(ncid, NC_GLOBAL, name, &len); if (ret == NC_ENOTATT) { /* Create the attribute. I will null-terminate this * attribute. */ if ((ret = nc_put_att_text(ncid, NC_GLOBAL, name, strlen(string) + 1, string))) return ret; } else if (ret == NC_NOERR) { /* The attribute already exists. Get memory to hold the existing * att plus our version string. Add one for the space, and one * for a terminating null. */ new_len = len + strlen(string) + 1; if (!(att_str = malloc(new_len + 1))) return CF_ENOMEM; /* Get the existing attribute value. */ if ((ret = nc_get_att_text(ncid, NC_GLOBAL, name, att_str))) BAIL(CF_ENETCDF); /* If it's already in the string, our work is done.*/ if (strstr(att_str, string)) { free(att_str); return CF_NOERR; } /* Append our string to the existing att. */ att_str[len] = 0; strcat(att_str, " "); strcat(att_str, string); /* Delete the existing attribute, so we can rewrite it. */ if ((ret = nc_del_att(ncid, NC_GLOBAL, name))) BAIL(ret); /* Rewrite the attribute with our string appended. */ if ((ret = nc_put_att_text(ncid, NC_GLOBAL, name, strlen(att_str) + 1, att_str))) BAIL(ret); }exit: if (att_str) free(att_str); return ret;}
开发者ID:alexjohn1362,项目名称:rose,代码行数:60,
示例9: pam5_stack_matchstatic voidpam5_stack_match(struct patternMatch *match){ struct atom *aGv1 = match->p->atoms[match->atomIndices[0]]; struct atom *aGv2 = match->p->atoms[match->atomIndices[1]]; struct atom *aS1a = match->p->atoms[match->atomIndices[2]]; struct atom *aS1b = match->p->atoms[match->atomIndices[3]]; struct atom *aS2a = match->p->atoms[match->atomIndices[4]]; struct atom *aS2b = match->p->atoms[match->atomIndices[5]]; struct atom *vA; struct atom *vB; struct bond *bond; int i; pam5_requires_gromacs(match->p); BAIL(); init_stack_match(); BAIL(); // S1a S2b // | | // Gv1----Gv2 // | | // S1b S2a if (!isExpectedTwist(match->p, aGv1, aGv2, aS1a, aS1b)) { aS1a = match->p->atoms[match->atomIndices[3]]; aS1b = match->p->atoms[match->atomIndices[2]]; } if (!isExpectedTwist(match->p, aGv2, aGv1, aS2a, aS2b)) { aS2a = match->p->atoms[match->atomIndices[5]]; aS2b = match->p->atoms[match->atomIndices[4]]; } // Atoms are now in canonical orientations. The twist is such that // the S1a-S2a distance is greater than the S1b-S2b distance in // BDNA. for (i=0; i<8 && i < numStruts; i++) { vA = makeVirtualAtom(vDa_type[i], sp3, 3, 1, aGv1, aS1a, aS1b, NULL, vDax_p[i], vDax_q[i], 0.0); vB = makeVirtualAtom(vDb_type[i], sp3, 3, 1, aGv2, aS2a, aS2b, NULL, vDbx_p[i], vDbx_q[i], 0.0); bond = makeBond(match->p, vA, vB, '1'); queueAtom(match->p, vA); trace_makeVirtualAtom(match, vA); queueAtom(match->p, vB); trace_makeVirtualAtom(match, vB); queueBond(match->p, bond); trace_makeBond(match, bond); } //printMatch(match);}
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:52,
示例10: fsync_dirstatic int fsync_dir(const char *name) { char *file = (char*) malloc(sizeof(char)*(strlen(name)+1)); strcpy(file, name); trim_rightmost_path_component(file); FP(stderr, " fsync-ing '%s'/n", file); int fd; if (-1 == (fd = open(file, O_RDONLY))) BAIL("open failed"); if (-1 == fsync(fd)) BAIL("fsync failed"); if (-1 == close(fd)) BAIL("close failed"); free(file); return 0;}
开发者ID:HewlettPackard,项目名称:Atlas,代码行数:13,
示例11: fplay_read_header/* fplay_read_header * * Read the header out of a file, and determine if it is WAV or ILDA. */int fplay_read_header(void) { char buf[8]; int ret = fplay_read(buf, 8); if (ret == 0) return 0; else if (ret != 8) BAIL("short read"); if (!memcmp(buf, "RIFF", 4)) { uint32_t wav_file_size = *(uint32_t *)(buf + 4); fplay_read_check(buf, 8); if (memcmp(buf, "WAVEfmt ", 8)) BAIL("RIFF file not WAV"); return wav_read_file_header(wav_file_size); } /* If it's not WAV, it had better be ILDA */ if (memcmp(buf, "ILDA/0/0/0", 7)) BAIL("file is not WAV or ILDA"); fplay_state = buf[7]; /* Read the rest of the header of this particular frame. */ switch (fplay_state) { case STATE_ILDA_0: case STATE_ILDA_1: case STATE_ILDA_4: case STATE_ILDA_5: /* 2D, 3D, and formats 4 and 5 */ ret = ilda_read_frame_header(); if (ret < 0) return ret; if (fplay_points_left < 0) BAIL("negative points in frame"); /* Zero-length means end of file */ if (fplay_points_left == 0) return 0; /* Save off the beginning of this frame, in case we * need to repeat it. */ fplay_frame_start.fptr = fplay_file.fptr; fplay_frame_start.curr_clust = fplay_file.curr_clust; fplay_frame_start.dsect = fplay_file.dsect; ilda_frame_pointcount = fplay_points_left; break; default: BAILV("ilda: bad format %d", fplay_state); } return 1;}
开发者ID:Janesak1977,项目名称:j4cDAC,代码行数:53,
示例12: FskFSFileMapFskErr FskFSFileMap(const char *fullPath, unsigned char **data, FskInt64 *dataSize, FskFSFileMapping *mapOut){ FskErr err = kFskErrNone; FskFSFileMapping map = NULL; FskInt64 size; int fp; struct stat statbuf; err = sCheckFullPath(fullPath, kFskPathIsFile); if (err) return err; err = FskMemPtrNewClear(sizeof(FskFSFileMappingRecord), (FskMemPtr*)(void*)&map); BAIL_IF_ERR(err); map->file = -1; fp = open(fullPath, O_RDONLY); if (fp < 0) BAIL(errnoToFskErr(errno)); map->file = fp; fstat(map->file, &statbuf); size = statbuf.st_size; if (size > 0xffffffff) BAIL(kFskErrOperationFailed); map->length = size; map->address = mmap(NULL, map->length, PROT_READ, MAP_SHARED, map->file, 0); if (MAP_FAILED == map->address) { map->address = NULL; BAIL(kFskErrOperationFailed); } *data = (unsigned char *)map->address; *dataSize = size;bail: if (kFskErrNone != err) { FskFSFileDisposeMap(map); map = NULL; } *mapOut = map; return err;}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:48,
示例13: FskSemaphoreNew_FskErr FskSemaphoreNew_(FskSemaphore *sem, UInt32 value, FSK_SYNCHRONIZATION_DEBUG_ARGS)#endif{ FskErr err; err = FskMemPtrNewClear(sizeof(FskSemaphoreRecord), (FskMemPtr *)sem); BAIL_IF_ERR(err); if (((*sem)->hSem = CreateSemaphore(NULL, value, 0x7fffffff, NULL)) == NULL) { BAIL(kFskErrOperationFailed); } FskInstrumentedItemNew(*sem, NULL, &gFskSemaphoreTypeInstrumentation);#if SUPPORT_INSTRUMENTATION && SUPPORT_SYNCHRONIZATION_DEBUG if (FskInstrumentedItemHasListeners(*sem)) { FskSynchronizationInstrMsgRecord msg; msg.file = file; msg.line = line; msg.function = function; FskInstrumentedItemSendMessage(*sem, kFskSynchronizationInstrMsgSemaphoreNew, &msg); }#endifbail: if ((err != kFskErrNone) && (*sem != NULL)) { FskMemPtrDispose(*sem); *sem = NULL; } return err;}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:31,
示例14: FskMutexNew_uninstrumentedFskErr FskMutexNew_uninstrumented(FskMutex *mutex, const char *name){ FskErr err; pthread_mutexattr_t attr; err = FskMemPtrNewClear(sizeof(FskMutexRecord), (FskMemPtr *)mutex); BAIL_IF_ERR(err); if ((pthread_mutexattr_init(&attr) != 0) || (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) || (pthread_mutex_init(&(*mutex)->mutex, &attr) != 0)) { BAIL(kFskErrOperationFailed); }#if SUPPORT_INSTRUMENTATION (*mutex)->name = FskStrDoCopy_Untracked(name);#endifbail: pthread_mutexattr_destroy(&attr); if ((err != kFskErrNone) && (*mutex != NULL)) {#if SUPPORT_INSTRUMENTATION FskMemPtrDispose((FskMemPtr)(*mutex)->name);#endif FskMemPtrDispose(*mutex); *mutex = NULL; } return err;}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:30,
示例15: BAIL_ON_FAILURE//// convert unicode string to auth type//HRESULTWstr2AuthType( IN LPCWSTR pszSrc, OUT PIHV_AUTH_TYPE pAuthType){ HRESULT hr = S_OK; DWORD dwIndex = 0; if ( (!pAuthType) || (!pszSrc) ) { hr = E_INVALIDARG; BAIL_ON_FAILURE( hr ); } for ( dwIndex = 0; dwIndex < MAX_AUTH_TYPES; dwIndex++ ) { if ( 0 == wcscmp( gppszIhvAuthTypes[dwIndex], pszSrc ) ) { (*pAuthType) = (IHV_AUTH_TYPE) dwIndex; BAIL( ); } } // String not found. hr = E_INVALIDARG; BAIL_ON_FAILURE( hr );error: return hr;}
开发者ID:kcrazy,项目名称:winekit,代码行数:36,
示例16: evaluateGradientFromPotentialvoidevaluateGradientFromPotential(struct configuration *p){ struct functionDefinition *fd; struct configuration *pPlusDelta = NULL; struct configuration *pMinusDelta = NULL; int i; int j; NULLPTR(p); fd = p->functionDefinition; NULLPTR(fd); if (fd->gradient_delta == 0.0) { fd->gradient_delta = 1e-8; } for (i=0; i<fd->dimension; i++) { pPlusDelta = makeConfiguration(fd); for (j=0; j<fd->dimension; j++) { pPlusDelta->coordinate[j] = p->coordinate[j]; } pPlusDelta->coordinate[i] += fd->gradient_delta / 2.0; pMinusDelta = makeConfiguration(fd); for (j=0; j<fd->dimension; j++) { pMinusDelta->coordinate[j] = p->coordinate[j]; } pMinusDelta->coordinate[i] -= fd->gradient_delta / 2.0; p->gradient[i] = (evaluate(pMinusDelta) - evaluate(pPlusDelta)) / fd->gradient_delta; BAIL(); SetConfiguration(&pPlusDelta, NULL); SetConfiguration(&pMinusDelta, NULL); }}
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:34,
示例17: pam5_basepair_matchstatic voidpam5_basepair_match(struct patternMatch *match){ struct atom *aS1 = match->p->atoms[match->atomIndices[1]]; struct atom *aS2 = match->p->atoms[match->atomIndices[2]]; struct bond *bond; pam5_requires_gromacs(match->p); BAIL(); init_stack_match(); BAIL(); bond = makeBond(match->p, aS1, aS2, '1'); queueBond(match->p, bond); trace_makeBond(match, bond); //printMatch(match);}
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:16,
示例18: FskGPIONewstatic FskErr FskGPIONew(FskGPIO *gpioOut, int pin, char *pinName, GPIOdirection direction){ FskErr err = kFskErrNone; FskGPIO gpio = NULL; err = FskMemPtrNewClear(sizeof(FskGPIORecord), (FskMemPtr *)&gpio); BAIL_IF_ERR(err); gpio->pinNum = pin; gpio->realPin = FskHardwarePinsMux(pin, kFskHardwarePinGPIO); gpio->thread = FskThreadGetCurrent(); if (gpio->realPin < 0) BAIL(kFskErrInvalidParameter); err = FskGPIOPlatformInit(gpio); BAIL_IF_ERR(err); if (undefined != direction) { err = FskGPIOPlatformSetDirection(gpio, direction); BAIL_IF_ERR(err); }bail: if (err && gpio) { FskGPIOPlatformDispose(gpio); FskMemPtrDisposeAt(&gpio); } *gpioOut = gpio; return err;}
开发者ID:kouis3940,项目名称:kinomajs,代码行数:33,
示例19: FskPinI2CNewFskErr FskPinI2CNew(FskPinI2C *pin, SInt32 sda, SInt32 sclk, SInt32 bus){ FskErr err; FskPinI2CDispatch dispatch = NULL; UInt32 i = 0; while (true) { SInt32 remappedBus = kFskPinI2CNoBus; FskPinI2CDispatch aDispatch = FskExtensionGetByIndex(kFskExtensionPinI2C, i++); if (NULL == aDispatch) BAIL(kFskErrExtensionNotFound); if ((aDispatch->doCanHandle)(sda, sclk, bus, &remappedBus)) { dispatch = aDispatch; break; } if (kFskPinI2CNoBus != remappedBus) bus = remappedBus; } err = (dispatch->doNew)(pin, sda, sclk, bus); BAIL_IF_ERR(err); (*pin)->dispatch = dispatch;bail: return err;}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:29,
示例20: FskPinAnalogNewFskErr FskPinAnalogNew(FskPinAnalog *pin, SInt32 number, const char *name){ FskErr err; FskPinAnalogDispatch dispatch = NULL; UInt32 i = 0; while (true) { FskPinAnalogDispatch aDispatch = FskExtensionGetByIndex(kFskExtensionPinAnalog, i++); if (NULL == aDispatch) BAIL(kFskErrExtensionNotFound); if ((aDispatch->doCanHandle)(number, name, &number)) { dispatch = aDispatch; break; } } err = (dispatch->doNew)(pin, number, name); BAIL_IF_ERR(err); (*pin)->dispatch = dispatch;bail: return err;}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:25,
示例21: BAIL_ON_FAILURE//// convert unicode string to cipher type//HRESULTWstr2CipherType( _In_ LPCWSTR pszSrc, _Out_ PIHV_CIPHER_TYPE pCipherType){ HRESULT hr = S_OK; DWORD dwIndex = 0; if ( (!pCipherType) || (!pszSrc) ) { hr = E_INVALIDARG; BAIL_ON_FAILURE( hr ); } for ( dwIndex = 0; dwIndex < MAX_CIPHER_TYPES; dwIndex++ ) { if ( 0 == wcscmp( gppszIhvCipherTypes[dwIndex], pszSrc ) ) { (*pCipherType) = (IHV_CIPHER_TYPE) dwIndex; BAIL( ); } } // String not found. hr = E_INVALIDARG; BAIL_ON_FAILURE( hr );error: return hr;}
开发者ID:0xhack,项目名称:Windows-driver-samples,代码行数:36,
示例22: nccf_inq_conventionintnccf_inq_convention(int ncid, int *cf_convention){ size_t len, new_len; char *existing_att = NULL; int ret = CF_NOERR; /* Find out if there is a conventions attribute. */ ret = nc_inq_attlen(ncid, NC_GLOBAL, CF_CONVENTIONS, &len); if (ret == NC_NOERR) { /* Get memory to hold the existing att plus our version * string. */ new_len = len + strlen(CF_CONVENTION_STRING) + 1; if (!(existing_att = malloc(new_len))) return CF_ENOMEM; /* Get the existing att. */ if ((ret = nc_get_att_text(ncid, NC_GLOBAL, CF_CONVENTIONS, existing_att))) BAIL(CF_ENETCDF); /* If it's already in the string, our work is done.*/ if (strstr(existing_att, CF_CONVENTION_STRING)) { if (cf_convention) *cf_convention = 1; ret = CF_NOERR; } } else if (ret == NC_ENOTATT) { /* No conventions att means no cf conventions. ;-( But this is * not an error. */ if (cf_convention) *cf_convention = 0; ret = NC_NOERR; } else BAIL(CF_ENETCDF);exit: if (existing_att) free(existing_att); return ret;}
开发者ID:alexjohn1362,项目名称:rose,代码行数:47,
示例23: fsync_paranoidstatic int fsync_paranoid(const char *name) { char rp[1+PATH_MAX], *file = (char *) malloc(sizeof(char)*(strlen(name)+1)); strcpy(file, name); FP(stderr, "fsync to root '%s'/n", file); if (NULL == realpath(file, rp)) BAIL("realpath failed"); FP(stderr, " realpath '%s'/n", rp); do { int fd; FP(stderr, " fsync-ing '%s'/n", rp); if (-1 == (fd = open(rp, O_RDONLY))) BAIL("open failed"); if (-1 == fsync(fd)) BAIL("fsync failed"); if (-1 == close(fd)) BAIL("close failed"); trim_rightmost_path_component(rp); } while (*rp); FP(stderr, " done/n"); free(file); return 0;}
开发者ID:HewlettPackard,项目名称:Atlas,代码行数:18,
示例24: ASSERT// base function to obtain text from// node described by XPATH.HRESULTCIhvProfileBase::GetTextFromNode( IN LPCWSTR pszQuery, OUT BSTR* pbstrText){ HRESULT hr = S_OK; BSTR bstrQuery = NULL; IXMLDOMNode* pQueryNode = NULL; ASSERT( pszQuery ); ASSERT( pbstrText ); // if node is NULL, return empty string. if ( !m_pRootNode ) { hr = Wstr2Bstr ( L"", pbstrText ); BAIL( ); } hr = Wstr2Bstr ( pszQuery, &bstrQuery ); BAIL_ON_FAILURE( hr ); hr = m_pRootNode->selectSingleNode( bstrQuery, &pQueryNode ); BAIL_ON_FAILURE( hr ); if (!pQueryNode) { hr = E_UNEXPECTED; BAIL_ON_FAILURE( hr ); } hr = pQueryNode->get_text( pbstrText ); BAIL_ON_FAILURE( hr ); if ( !(*pbstrText) ) { hr = E_UNEXPECTED; BAIL_ON_FAILURE( hr ); }error: RELEASE_INTERFACE( pQueryNode ); SYS_FREE_STRING( bstrQuery ); return hr;}
开发者ID:0xhack,项目名称:Windows-driver-samples,代码行数:59,
示例25: ring_addvoid ring_add(Node *node) { num_nodes++; if ((nodes = realloc(nodes, sizeof(void*) * num_nodes)) == NULL) { BAIL("Failed to realloc rings array"); } nodes[num_nodes] = node;}
开发者ID:111220187,项目名称:chord,代码行数:9,
示例26: KprDBStatementNewFskErr KprDBStatementNew(KprDBStatement* it, KprDB db, const char* text, char* bindFormat, char* rowFormat){ FskErr err = kFskErrNone; KprDBStatement self = NULL; SInt32 count, size, i; bailIfError(KprMemPtrNewClear(sizeof(KprDBStatementRecord), it)); self = *it; FskInstrumentedItemNew(self, NULL, &KprDBStatementInstrumentation); bailIfError(sqlite3_prepare_v2(db->data, text, FskStrLen(text), &self->data, NULL)); count = sqlite3_bind_parameter_count(self->data); if (count && !bindFormat) BAIL(kFskErrInvalidParameter); if (!count && bindFormat) BAIL(kFskErrInvalidParameter); if (count) { if ((SInt32)FskStrLen(bindFormat) != count) BAIL(kFskErrInvalidParameter); self->bindFormat = FskStrDoCopy(bindFormat); bailIfNULL(self->bindFormat); } count = sqlite3_column_count(self->data); if (count && !rowFormat) BAIL(kFskErrInvalidParameter); if (!count && rowFormat) BAIL(kFskErrInvalidParameter); if (count) { if ((SInt32)FskStrLen(rowFormat) != count) BAIL(kFskErrInvalidParameter); self->rowFormat = FskStrDoCopy(rowFormat); bailIfNULL(self->rowFormat); bailIfError(KprMemPtrNewClear(count * sizeof(char*), &self->keys)); for (size = 0, i = 0; rowFormat[i]; i++) { self->keys[i] = sqlite3_column_name(self->data, i); switch (rowFormat[i]) { case 'b': size += sizeof(void*) + sizeof(UInt32); break; case 'd': size += sizeof(double); break; case 'i': size += sizeof(SInt32); break; case 'I': size += sizeof(FskInt64); break; case 'r': size += sizeof(SInt32); break; case 't': size += sizeof(char*); break; default: BAIL(kFskErrInvalidParameter); break; } } bailIfError(KprMemPtrNewClear(size, &self->values)); }bail: if (err) KprDBStatementDispose(self); return err;}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:58,
示例27: pam5_groove_phosphate_match// Creates the Gv-Pl interaction, which replaces the Gv-Ss-Pl bend// term. Only do this on the 5' side.static voidpam5_groove_phosphate_match(struct patternMatch *match){ struct part *p = match->p; struct atom *aGv = p->atoms[match->atomIndices[0]]; struct atom *aSs = p->atoms[match->atomIndices[1]]; struct atom *aPl = p->atoms[match->atomIndices[2]]; struct bond *b = getBond(p, aPl, aSs); BAIL(); struct bond *bond; struct bend *bend; int reverse; char order; pam5_requires_gromacs(p); BAIL(); switch (b->direction) { case 'F': reverse = (b->a1 == aSs); break; case 'R': reverse = (b->a1 == aPl); break; default: ERROR2("pam5_phosphate_sugar_match: bond between ids %d and %d has no direction", aPl->atomID, aSs->atomID); p->parseError(p->stream); return; } if (reverse) { order = '2'; } else { order = '1'; bend = getBend(p, aGv, aSs, aPl); bend->bendType = bend_Gv_Ss_Pl_5; } bond = makeBond(p, aPl, aGv, order); queueBond(p, bond); trace_makeBond(match, bond); //printMatch(match);}
开发者ID:alaindomissy,项目名称:nanoengineer,代码行数:45,
示例28: mainintmain(){ int ncid, temp_varid, dimids[NUMDIMS]; float temp[LAT_LEN][LON_LEN], *fp; char classic_file[] = "classic.nc", offset64_file[] = "offset.nc"; char *file = classic_file; int i, res; /* Create a bunch of phoney data so we have something to write in the example file. */ for (fp=(float *)temp, i=0; i<LAT_LEN*LON_LEN; i++) *fp++ = 10. + i/10.; /* Now create the file in both formats with the same code. */ for (i=0; i<2; i++) { if (i==1) /* 64-bit offset format file */ { file = offset64_file; if ((res = nc_set_default_format(NC_FORMAT_64BIT, NULL))) BAIL(res); } /* Create the netCDF file. */ if ((res = nc_create(file, NC_CLOBBER, &ncid))) BAIL(res); /* Define dimensions. */ if ((res = nc_def_dim(ncid, "latitude", LAT_LEN, dimids))) BAIL(res); if ((res = nc_def_dim(ncid, "longitude", LON_LEN, &dimids[1]))) BAIL(res); /* Define the variable. */ if ((res = nc_def_var(ncid, "sfc_temp", NC_FLOAT, NUMDIMS, dimids, &temp_varid))) BAIL(res); /* We're finished defining metadata. */ if ((res = nc_enddef(ncid))) BAIL(res); if ((res = nc_put_var_float(ncid, temp_varid, (float *)temp))) BAIL(res); /* We're done! */ if ((res = nc_close(ncid))) BAIL(res); } return 0;}
开发者ID:BJangeofan,项目名称:netcdf-c,代码行数:53,
注:本文中的BAIL函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ BAIL_IF_ERR函数代码示例 C++ BAD_MADT_ENTRY函数代码示例 |