本文整理汇总了C++中BAIL函数的典型用法代码示例。如果您正苦于以下问题:C++ BAIL函数的具体用法?C++ BAIL怎么用?C++ BAIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BAIL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FskFSFileRename
FskErr 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,代码来源:FskFilesAndroid.c
示例2: pam5_basepair_handle_match
static void
pam5_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,代码来源:pam5_patterns.c
示例3: evaluateGradient
void
evaluateGradient(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,代码来源:minimize.c
示例4: alloc_monitoring_datas
int 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,代码来源:rackmond.c
示例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 void
pam5_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,代码来源:pam5_patterns.c
示例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,代码来源:FskFilesAndroid.c
示例7: dircopy
int 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,代码来源:pcp.c
示例8: nccf_append_att
/* Append string to a named global attribute. Create the attribute if
* it doesn't exist. */
static int
nccf_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,代码来源:cffiles.c
示例9: pam5_stack_match
static void
pam5_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,代码来源:pam5_patterns.c
示例10: fsync_dir
static 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,代码来源:fsync.hpp
示例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,代码来源:ild-player.c
示例12: FskFSFileMap
FskErr 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,代码来源:FskFilesAndroid.c
示例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);
}
#endif
bail:
if ((err != kFskErrNone) && (*sem != NULL)) {
FskMemPtrDispose(*sem);
*sem = NULL;
}
return err;
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:31,代码来源:FskSynchronization.c
示例14: FskMutexNew_uninstrumented
FskErr 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);
#endif
bail:
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,代码来源:FskSynchronization.c
示例15: BAIL_ON_FAILURE
//
// convert unicode string to auth type
//
HRESULT
Wstr2AuthType
(
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,代码来源:profile.cpp
示例16: evaluateGradientFromPotential
void
evaluateGradientFromPotential(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,代码来源:minimize.c
示例17: pam5_basepair_match
static void
pam5_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,代码来源:pam5_patterns.c
示例18: FskGPIONew
static 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,代码来源:gpio.c
示例19: FskPinI2CNew
FskErr 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,代码来源:FskPin.c
示例20: FskPinAnalogNew
FskErr 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,代码来源:FskPin.c
注:本文中的BAIL函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论