本文整理汇总了C++中BAIL_IF_ERR函数的典型用法代码示例。如果您正苦于以下问题:C++ BAIL_IF_ERR函数的具体用法?C++ BAIL_IF_ERR怎么用?C++ BAIL_IF_ERR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BAIL_IF_ERR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FskMuxerTrackNew
FskErr FskMuxerTrackNew(FskMuxer muxer, FskMuxerTrack *muxerTrackOut, const char *trackType, UInt32 scale)
{
FskErr err;
FskMuxerTrack track = NULL;
err = FskMemPtrNewClear(sizeof(FskMuxerTrackRecord) + FskStrLen(trackType) + 1, &track);
BAIL_IF_ERR(err);
track->trackType = (char *)(track + 1);
FskStrCopy(track->trackType, trackType);
track->scale = scale;
track->muxer = muxer;
err = (muxer->dispatch->doNewTrack)(muxer, muxer->state, track, &track->dispatch, &track->state);
BAIL_IF_ERR(err);
FskListAppend((FskList*)(void*)&muxer->tracks, track);
bail:
if (kFskErrNone != err) {
FskMuxerTrackDispose(track);
track = NULL;
}
*muxerTrackOut = track;
return err;
}
示例2: 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;
}
示例3: FskSemaphoreNew_
FskErr FskSemaphoreNew_(FskSemaphore *sem, UInt32 value, FSK_SYNCHRONIZATION_DEBUG_ARGS)
#endif
{
FskErr err;
err = FskMemPtrNewClear(sizeof(FskSemaphoreRecord), (FskMemPtr *)sem);
BAIL_IF_ERR(err);
err = KplSemaphoreNew((KplSemaphore*)&(*sem)->kplSem, value);
BAIL_IF_ERR(err);
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)) {
KplSemaphoreDispose((*sem)->kplSem);
FskMemPtrDispose(*sem);
*sem = NULL;
}
return err;
}
示例4: FskFSVolumeNotifierNew
FskErr FskFSVolumeNotifierNew(FskVolumeNotifierCallbackProc callback, void *refCon, FskFSVolumeNotifier *volNtfOut) {
FskErr err;
FskFSVolumeNotifier volNtf = NULL;
FskAndroidFilesPrintfDebug("VolumeNotifierNew\n");
if (NULL == gVolNotifiers) {
err = FskMutexNew(&gVolNotifiersMutex, "volume notifier");
BAIL_IF_ERR(err);
}
err = FskMemPtrNewClear(sizeof(FskFSVolumeNotifierRecord), (FskMemPtr*)(void*)&volNtf);
BAIL_IF_ERR(err);
FskMutexAcquire(gVolNotifiersMutex);
volNtf->dispatch.dispatch = &gFSDispatch;
volNtf->dispatch.refcon = NULL;
volNtf->callback = callback;
volNtf->refCon = refCon;
volNtf->callbackThread = FskThreadGetCurrent();
FskListPrepend(&gVolNotifiers, &volNtf->next);
FskMutexRelease(gVolNotifiersMutex);
bail:
*volNtfOut = volNtf;
return err;
}
示例5: sFskNetInterfaceEnumerate
static FskErr sFskNetInterfaceEnumerate(FskNetInterfaceRecord **interfaceList)
{
FskErr err;
KplNetInterfaceRecord *kplInterfaceList;
*interfaceList = NULL;
err = KplNetInterfaceEnumerate(&kplInterfaceList);
BAIL_IF_ERR(err);
while (kplInterfaceList) {
FskNetInterfaceRecord *nir;
KplNetInterfaceRecord *next = kplInterfaceList->next;
err = FskMemPtrNew(sizeof(FskNetInterfaceRecord), (FskMemPtr*)&nir);
BAIL_IF_ERR(err);
nir->name = FskStrDoCopy(kplInterfaceList->name);
nir->ip = kplInterfaceList->ip;
FskMemMove(nir->MAC, kplInterfaceList->MAC, sizeof(nir->MAC));
nir->status = kplInterfaceList->status;
nir->netmask = kplInterfaceList->netmask;
FskListAppend((FskList*)interfaceList, nir);
FskMemPtrDispose(kplInterfaceList->name);
FskMemPtrDispose(kplInterfaceList);
kplInterfaceList = next;
}
bail:
return err;
}
示例6: FskMutexNew_uninstrumented
FskErr FskMutexNew_uninstrumented(FskMutex *mutex, const char *name)
{
FskMutex mtx = NULL;
FskErr err;
err = FskMemPtrNewClear(sizeof(FskMutexRecord), (FskMemPtr *)&mtx);
BAIL_IF_ERR(err);
err = KplMutexNew((KplMutex*)&mtx->kplMutex);
BAIL_IF_ERR(err);
#if SUPPORT_INSTRUMENTATION
mtx->name = FskStrDoCopy_Untracked(name);
#endif
bail:
if ((err != kFskErrNone) && (mtx != NULL)) {
KplMutexDispose(mtx->kplMutex);
#if SUPPORT_INSTRUMENTATION
FskMemPtrDispose((void*)mtx->name);
#endif
FskMemPtrDispose(mtx);
mtx = NULL;
}
*mutex = mtx;
return err;
}
示例7: KprDebugMachineNew
FskErr KprDebugMachineNew(KprDebugMachine* it, KprDebug debug, FskSocket skt)
{
FskErr err = kFskErrNone;
KprDebugMachine self = NULL;
UInt32 ip;
int port;
BAIL_IF_ERR(err = FskMemPtrNewClear(sizeof(KprDebugMachineRecord), it));
self = *it;
self->debug = debug;
self->socket = skt;
BAIL_IF_ERR(err = FskNetSocketGetRemoteAddress(skt, &ip, &port));
FskNetIPandPortToString(ip, port, self->address);
FskListAppend(&self->debug->machine, self);
FskNetSocketReceiveBufferSetSize(self->socket, kSocketBufferSize);
FskThreadAddDataHandler(&self->reader, (FskThreadDataSource)self->socket, KprDebugMachineDataReader, true, false, self);
bailIfError(KprSocketWriterNew(&self->writer, self->socket, self));
self->writer->errorCallback = KprDebugMachineWriteError;
KprDebugMachineCallbackText(self, "onMachineRegistered", mxNoCommand, NULL);
FskInstrumentedItemNew(self, NULL, &KprDebugMachineInstrumentation);
return err;
bail:
KprDebugMachineDispose(self);
return err;
}
示例8: 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;
}
示例9: 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;
}
示例10: ButtEndCap
static FskErr
ButtEndCap(const LineSeg *seg, UInt32 end, FskGrowableFixedPoint2DArray array)
{
FskErr err;
FskFixedVector2D v;
FskFixedPoint2D p;
const FskFixedPoint2D *center;
v.x = FskFixedNMul(seg->perp.x, seg->strokeWidth, 31);
v.y = FskFixedNMul(seg->perp.y, seg->strokeWidth, 31);
if (!end) { /* Starting endpoint */
center = &seg->pt[0];
}
else { /* Ending endpoint */
v.x = -v.x;
v.y = -v.y;
center = &seg->pt[1];
}
p.x = center->x - v.x;
p.y = center->y - v.y;
BAIL_IF_ERR(err = FskGrowableFixedPoint2DArrayAppendItem(array, &p));
p.x = center->x + v.x;
p.y = center->y + v.y;
BAIL_IF_ERR(err = FskGrowableFixedPoint2DArrayAppendItem(array, &p));
bail:
return err;
}
示例11: BeveledJoin
static FskErr
BeveledJoin(const LineSeg *seg0, const LineSeg *seg1, FskGrowableFixedPoint2DArray fwdPoly, FskGrowableFixedPoint2DArray revPoly)
{
FskErr err = kFskErrNone;
FskFract sinAng, cosAng, snmHaf, sinHaf, cosHaf;
FskFixed bevHafWidth, mitLength, maxElbow;
FskFractVector2D u;
FskFixedVector2D b, c, e;
FskFixedPoint2D p[3];
sinAng = FskFractCrossProduct2D(&seg0->par, &seg1->par); /* Sine of change in trajectory */
if (sinAng == 0) /* Collinear */
goto bail; /* All done */
cosAng = FskFractDotProduct(&seg0->par.x, &seg1->par.x, 2); /* Cosine of change in trajectory */
if (cosAng > FRACT_ONE) cosAng = FRACT_ONE;
else if (cosAng < -FRACT_ONE) cosAng = -FRACT_ONE;
cosHaf = FskFracSqrt(FRACT_HALF - (cosAng >> 1)); /* Cosine of half the subtended angle */
snmHaf = FskFracSqrt(FRACT_HALF + (cosAng >> 1)); /* Sine of half the subtended angle */
if (snmHaf != 0) {
sinHaf = snmHaf;
if (sinAng < 0) sinHaf = -sinHaf;
u.x = FskFixedNLinear2D(seg0->par.x, cosHaf, seg0->par.y, sinHaf, 30); /* Unit vector to elbow, inside or outside */
u.y = FskFixedNLinear2D(seg0->par.y, cosHaf, -seg0->par.x, sinHaf, 30);
bevHafWidth = (FskFixed)(((FskInt64)(seg0->strokeWidth) * cosHaf / (FRACT_ONE + snmHaf) + 1) >> 1);
c.x = FskFixedNMul(seg0->strokeWidth, u.x, 31); /* Midpoint of bevel */
c.y = FskFixedNMul(seg0->strokeWidth, u.y, 31);
b.x = FskFracMul(bevHafWidth, -u.y); /* Half-vector of bevel */
b.y = FskFracMul(bevHafWidth, u.x);
mitLength = FskFixedNDiv(seg0->strokeWidth, snmHaf, 29);
if ((maxElbow = (seg0->strokeWidth)) < seg0->length) /* Limit the extent of the inside bevel joint */
maxElbow = seg0->length;
if (maxElbow < seg1->length)
maxElbow = seg1->length;
if (mitLength > maxElbow)
mitLength = maxElbow;
e.x = FskFracMul(mitLength, u.x); /* Scaled vector to elbow, inside */
e.y = FskFracMul(mitLength, u.y);
if (sinAng > 0) { /* Positive rotation */
p[0].x = seg0->pt[1].x + c.x - b.x; /* First bevel point */
p[0].y = seg0->pt[1].y + c.y - b.y;
p[1].x = seg0->pt[1].x + c.x + b.x; /* Second bevel point */
p[1].y = seg0->pt[1].y + c.y + b.y;
p[2].x = seg0->pt[1].x - e.x; /* Inside elbow */
p[2].y = seg0->pt[1].y - e.y;
BAIL_IF_ERR(err = FskGrowableFixedPoint2DArrayAppendItems(revPoly, &p[0], 2));
BAIL_IF_ERR(err = FskGrowableFixedPoint2DArrayAppendItem( fwdPoly, &p[2]));
}
else { /* Negative rotation */
p[0].x = seg0->pt[1].x + c.x + b.x; /* First bevel point */
p[0].y = seg0->pt[1].y + c.y + b.y;
p[1].x = seg0->pt[1].x + c.x - b.x; /* Second bevel point */
p[1].y = seg0->pt[1].y + c.y - b.y;
p[2].x = seg0->pt[1].x - e.x; /* Inside elbow */
p[2].y = seg0->pt[1].y - e.y;
BAIL_IF_ERR(err = FskGrowableFixedPoint2DArrayAppendItems(fwdPoly, &p[0], 2));
BAIL_IF_ERR(err = FskGrowableFixedPoint2DArrayAppendItem( revPoly, &p[2]));
}
}
示例12: FskFramePolygon
FskErr
FskFramePolygon(
UInt32 nPts,
const FskFixedPoint2D *pts,
FskFixed strokeWidth,
FskFixed jointSharpness,
const FskColorSource *frameColor,
const FskFixedMatrix3x2 *M,
UInt32 quality,
FskConstRectangle clipRect,
FskBitmap dstBM
)
{
FskErr err;
const FskColorSource *frameFillColors[2];
if (frameColor->dashCycles != 0) /* Do special processing for dashed lines: @@@ should have endcap spec for dashes */
return FrameDashedPolyLine(nPts, pts, strokeWidth, jointSharpness, kFskLineEndCapClosed|kFskLineEndCapButt, frameColor, M, quality, clipRect, dstBM);
if (M) strokeWidth = ScaleStrokeWidth(strokeWidth, M);
if ( (strokeWidth <= FIXED_ONE)
&& (frameColor->type == kFskColorSourceTypeConstant)
) {
if (quality == 0) {
FskConstColorRGB frColor = (FskConstColorRGB)(void*)(&(((const FskColorSourceConstant*)(void*)frameColor)->color));
err = FrameJaggyNarrowPolyLine( nPts, pts, 1, frColor, M, clipRect, dstBM);
} else {
frameFillColors[0] = frameColor;
frameFillColors[1] = NULL;
err = FskAAPolygonContours(1, &nPts, pts, FIXED_ONE, frameFillColors, -1, M, clipRect, dstBM);
}
}
else {
FskGrowableFixedPoint2DArray pgon = NULL;
UInt32 n;
FskFixedPoint2D *p;
BAIL_IF_ERR(err = FskWidePolyLineToPolygon(nPts, pts, strokeWidth, jointSharpness, kFskLineEndCapClosed, M, &pgon));
BAIL_IF_ZERO((n = FskGrowableFixedPoint2DArrayGetItemCount(pgon)), err, kFskErrNothingRendered);
BAIL_IF_ERR(err = FskGrowableFixedPoint2DArrayGetPointerToItem(pgon, 0, (void**)(void*)(&p)));
if (quality == 0) {
err = FillJaggyPolygonContours(1, &n, p, frameColor, kFskFillRuleNonZero, NULL, clipRect, dstBM);
} else {
frameFillColors[0] = NULL;
frameFillColors[1] = frameColor;
err = FskAAPolygonContours( 1, &n, p, -1, frameFillColors, kFskFillRuleNonZero, NULL, clipRect, dstBM);
}
bail:
if (pgon != NULL) FskGrowableFixedPoint2DArrayDispose(pgon);
}
return err;
}
示例13: httpServerListenerStart
static FskErr httpServerListenerStart(FskHTTPServerListener listener, FskSocket skt) {
FskErr err = kFskErrNone;
FskHTTPServerRequest request;
if (listener->http->stopped) {
FskInstrumentedItemSendMessage(listener->http, kFskHTTPInstrMsgConnectionRefusedStopped, listener);
listener->http->stats.connectionsRefused++;
FskNetSocketClose(skt);
goto bail;
}
err = FskMemPtrNewClear(sizeof(FskHTTPServerRequestRecord), (FskMemPtr*)&request);
BAIL_IF_ERR(err);
sFskHTTPServerRequestUpUse(request);
request->http = listener->http;
request->skt = skt;
FskNetSocketGetRemoteAddress(skt, (UInt32 *)&request->requesterAddress, &request->requesterPort);
FskNetSocketMakeNonblocking(request->skt);
err = FskHeaderStructNew(&request->requestHeaders);
BAIL_IF_ERR(err);
err = FskHeaderStructNew(&request->responseHeaders);
BAIL_IF_ERR(err);
request->in.bufferSize = request->http->defaultBufferSize;
request->out.bufferSize = request->http->defaultBufferSize;
err = FskMemPtrNew(request->in.bufferSize, (FskMemPtr*)&request->in.buf);
BAIL_IF_ERR(err);
err = FskMemPtrNew(request->out.bufferSize, (FskMemPtr*)&request->out.buf);
BAIL_IF_ERR(err);
FskListAppend((FskList*)&request->http->activeRequests, request);
FskTimeCallbackNew(&request->cycleCallback);
FskTimeCallbackNew(&request->keepAliveKillCallback);
listener->http->stats.connectionsMade++;
request->state = kHTTPNewSession;
FskInstrumentedItemNew(request, NULL, &gFskHTTPServerRequestTypeInstrumentation);
FskInstrumentedItemSetOwner(request, request->http);
FskTimeCallbackScheduleNextRun(request->cycleCallback, httpServerTimeCycle, request);
doCallCondition(request->http->callbacks->requestCondition, request, kFskHTTPConditionConnectionInitialized, request->refCon);
FskTimeCallbackNew(&request->timer);
FskTimeCallbackScheduleFuture(request->timer, 1, 0, KprHTTPServerTimerCallback, request);
bail:
if (err)
FskHTTPServerRequestDispose(request);
return err;
}
示例14: FskAudioDecompressNew
FskErr FskAudioDecompressNew(FskAudioDecompress *decoOut, UInt32 audioFormat, const char *mimeType, UInt32 sampleRate, UInt32 channelCount, void *formatInfo, UInt32 formatInfoSize)
{
FskErr err;
FskAudioDecompressor decoder;
FskAudioDecompress deco;
UInt32 i = 0;
while (true) {
Boolean canHandle = false;
decoder = (FskAudioDecompressor)FskExtensionGetByIndex(kFskExtensionAudioDecompressor, i++);
if (NULL == decoder) {
if (decoOut)
*decoOut = NULL;
return kFskErrExtensionNotFound;
}
if ((kFskErrNone == decoder->doCanHandle(audioFormat, mimeType, &canHandle)) && canHandle)
break;
}
if (NULL == decoOut)
return kFskErrNone; // can handler
err = FskMemPtrNewClear(sizeof(FskAudioDecompressRecord), &deco);
BAIL_IF_ERR(err);
deco->inputSampleRate = sampleRate;
deco->inputChannelCount = channelCount;
deco->outputChannelCount = channelCount;
deco->formatInfoSize = formatInfoSize;
err = FskMemPtrNewFromData(formatInfoSize, formatInfo, (FskMemPtr*)(void*)&deco->formatInfo);
BAIL_IF_ERR(err);
deco->decoder = decoder;
FskInstrumentedItemNew(deco, FskStrDoCopy_Untracked(mimeType), &gAudioDecompressTypeInstrumentation);
err = deco->decoder->doNew(deco, audioFormat, mimeType);
BAIL_IF_ERR(err);
bail:
if (err) {
FskAudioDecompressDispose(deco);
deco = NULL;
}
*decoOut = deco;
return err;
}
示例15: 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;
}