当前位置: 首页>>代码示例>>C++>>正文


C++ BAIL_IF_MACRO函数代码示例

本文整理汇总了C++中BAIL_IF_MACRO函数的典型用法代码示例。如果您正苦于以下问题:C++ BAIL_IF_MACRO函数的具体用法?C++ BAIL_IF_MACRO怎么用?C++ BAIL_IF_MACRO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了BAIL_IF_MACRO函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BAIL_IF_MACRO

void *__PHYSFS_platformCreateMutex(void)
{
    int rc;
    PthreadMutex *m = (PthreadMutex *) allocator.Malloc(sizeof (PthreadMutex));
    BAIL_IF_MACRO(m == NULL, ERR_OUT_OF_MEMORY, NULL);
    rc = pthread_mutex_init(&m->mutex, NULL);
    if (rc != 0)
    {
        allocator.Free(m);
        BAIL_MACRO(strerror(rc), NULL);
    } /* if */

    m->count = 0;
    m->owner = (pthread_t) 0xDEADBEEF;
    return ((void *) m);
} /* __PHYSFS_platformCreateMutex */
开发者ID:AndroidAppList,项目名称:Android-Supertux,代码行数:16,代码来源:platform_unix.c

示例2: ZIP_fileClose

static int ZIP_fileClose(fvoid *opaque)
{
    ZIPfileinfo *finfo = (ZIPfileinfo *) opaque;
    BAIL_IF_MACRO(!__PHYSFS_platformClose(finfo->handle), NULL, 0);

    if (finfo->entry->compression_method != COMPMETH_NONE)
        inflateEnd(&finfo->stream);

	/* FIXME clean AES context */

    if (finfo->buffer != NULL)
        allocator.Free(finfo->buffer);

    allocator.Free(finfo);
    return(1);
} /* ZIP_fileClose */
开发者ID:Dahrkael,项目名称:PhysFS-AES,代码行数:16,代码来源:zip.c

示例3: BAIL_IF_MACRO

static char *unicodeToUtf8Heap(const WCHAR *w_str)
{
    char *retval = NULL;
    if (w_str != NULL)
    {
        void *ptr = NULL;
        const PHYSFS_uint64 len = (wStrLen(w_str) * 4) + 1;
        retval = allocator.Malloc(len);
        BAIL_IF_MACRO(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
        PHYSFS_utf8FromUtf16((const PHYSFS_uint16 *) w_str, retval, len);
        ptr = allocator.Realloc(retval, strlen(retval) + 1); /* shrink. */
        if (ptr != NULL)
            retval = (char *) ptr;
    } /* if */
    return retval;
} /* unicodeToUtf8Heap */
开发者ID:Jopnal,项目名称:physfs,代码行数:16,代码来源:platform_windows.c

示例4: malloc

static DirHandle *HOG_openArchive(const char *name, int forWriting)
{
    HOGinfo *info;
    DirHandle *retval = malloc(sizeof (DirHandle));
    PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);

    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    info = retval->opaque = malloc(sizeof (HOGinfo));
    if (info == NULL)
    {
        __PHYSFS_setError(ERR_OUT_OF_MEMORY);
        goto HOG_openArchive_failed;
    } /* if */

    memset(info, '\0', sizeof (HOGinfo));

    info->filename = (char *) malloc(strlen(name) + 1);
    if (info->filename == NULL)
    {
        __PHYSFS_setError(ERR_OUT_OF_MEMORY);
        goto HOG_openArchive_failed;
    } /* if */

    if (!hog_load_entries(name, forWriting, info))
        goto HOG_openArchive_failed;

    strcpy(info->filename, name);
    info->last_mod_time = modtime;
    retval->funcs = &__PHYSFS_DirFunctions_HOG;
    return(retval);

HOG_openArchive_failed:
    if (retval != NULL)
    {
        if (retval->opaque != NULL)
        {
            if (info->filename != NULL)
                free(info->filename);
            if (info->entries != NULL)
                free(info->entries);
            free(info);
        } /* if */
        free(retval);
    } /* if */

    return(NULL);
} /* HOG_openArchive */
开发者ID:UIKit0,项目名称:paragui,代码行数:47,代码来源:hog.c

示例5: read_fmt_chunk

/*
 * Read in a fmt_t from disk. This makes this process safe regardless of
 *  the processor's byte order or how the fmt_t structure is packed.
 * Note that the union "fmt" is not read in here; that is handled as 
 *  needed in the read_fmt_* functions.
 */
static int read_fmt_chunk(SDL_RWops *rw, fmt_t *fmt)
{
    /* skip reading the chunk ID, since it was already read at this point... */
    fmt->chunkID = fmtID;

    BAIL_IF_MACRO(!read_le32(rw, &fmt->chunkSize), NULL, 0);
    BAIL_IF_MACRO(fmt->chunkSize < 16, "WAV: Invalid chunk size", 0);
    fmt->next_chunk_offset = SDL_RWtell(rw) + fmt->chunkSize;
    
    BAIL_IF_MACRO(!read_le16(rw, &fmt->wFormatTag), NULL, 0);
    BAIL_IF_MACRO(!read_le16(rw, &fmt->wChannels), NULL, 0);
    BAIL_IF_MACRO(!read_le32(rw, &fmt->dwSamplesPerSec), NULL, 0);
    BAIL_IF_MACRO(!read_le32(rw, &fmt->dwAvgBytesPerSec), NULL, 0);
    BAIL_IF_MACRO(!read_le16(rw, &fmt->wBlockAlign), NULL, 0);
    BAIL_IF_MACRO(!read_le16(rw, &fmt->wBitsPerSample), NULL, 0);

    return(1);
} /* read_fmt_chunk */
开发者ID:BPaden,项目名称:garglk,代码行数:24,代码来源:wav.c

示例6: sizeof

char *__PHYSFS_platformGetUserName(void)
{
	DWORD bufsize = 0;
	char *retval = NULL;

	if (pGetUserNameW(NULL, &bufsize) == 0)  /* This SHOULD fail. */
	{
		LPWSTR wbuf = (LPWSTR)__PHYSFS_smallAlloc(bufsize * sizeof(WCHAR));
		BAIL_IF_MACRO(wbuf == NULL, ERR_OUT_OF_MEMORY, NULL);
		if (pGetUserNameW(wbuf, &bufsize) == 0)  /* ?! */
			__PHYSFS_setError(winApiStrError());
		else
			retval = unicodeToUtf8Heap(wbuf);
		__PHYSFS_smallFree(wbuf);
	} /* if */

	return(retval);
} /* __PHYSFS_platformGetUserName */
开发者ID:ahrnbom,项目名称:physfs-uwp,代码行数:18,代码来源:winrt.cpp

示例7: Sound_Rewind

int Sound_Rewind(Sound_Sample *sample)
{
    Sound_SampleInternal *internal;
    BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0);

    internal = (Sound_SampleInternal *) sample->opaque;
    if (!internal->funcs->rewind(sample))
    {
        sample->flags |= SOUND_SAMPLEFLAG_ERROR;
        return(0);
    } /* if */

    sample->flags &= ~SOUND_SAMPLEFLAG_EAGAIN;
    sample->flags &= ~SOUND_SAMPLEFLAG_ERROR;
    sample->flags &= ~SOUND_SAMPLEFLAG_EOF;

    return(1);
} /* Sound_Rewind */
开发者ID:AvelNaytroud,项目名称:libsdl-sound,代码行数:18,代码来源:SDL_sound.c

示例8: BAIL_IF_MACRO

static LinkedStringList *HOG_enumerateFiles(DirHandle *h,
                                            const char *dirname,
                                            int omitSymLinks)
{
    HOGinfo *info = ((HOGinfo *) h->opaque);
    HOGentry *entry = info->entries;
    LinkedStringList *retval = NULL, *p = NULL;
    PHYSFS_uint32 max = info->entryCount;
    PHYSFS_uint32 i;

    /* no directories in HOG files. */
    BAIL_IF_MACRO(*dirname != '\0', ERR_NOT_A_DIR, NULL);

    for (i = 0; i < max; i++, entry++)
        retval = __PHYSFS_addToLinkedStringList(retval, &p, entry->name, -1);

    return(retval);
} /* HOG_enumerateFiles */
开发者ID:UIKit0,项目名称:paragui,代码行数:18,代码来源:hog.c

示例9: Sound_Quit

int Sound_Quit(void)
{
    ErrMsg *err;
    ErrMsg *nexterr = NULL;
    size_t i;

    BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0);

    while (((volatile Sound_Sample *) sample_list) != NULL)
        Sound_FreeSample(sample_list);

    initialized = 0;

    SDL_DestroyMutex(samplelist_mutex);
    samplelist_mutex = NULL;
    sample_list = NULL;

    for (i = 0; decoders[i].funcs != NULL; i++)
    {
        if (decoders[i].available)
        {
            decoders[i].funcs->quit();
            decoders[i].available = 0;
        } /* if */
    } /* for */

    if (available_decoders != NULL)
        free((void *) available_decoders);
    available_decoders = NULL;

    /* clean up error state for each thread... */
    SDL_LockMutex(errorlist_mutex);
    for (err = error_msgs; err != NULL; err = nexterr)
    {
        nexterr = err->next;
        free(err);
    } /* for */
    error_msgs = NULL;
    SDL_UnlockMutex(errorlist_mutex);
    SDL_DestroyMutex(errorlist_mutex);
    errorlist_mutex = NULL;

    return(1);
} /* Sound_Quit */
开发者ID:AvelNaytroud,项目名称:libsdl-sound,代码行数:44,代码来源:SDL_sound.c

示例10: BAIL_IF_MACRO

static UNPKentry *slbLoadEntries(PHYSFS_Io *io, PHYSFS_uint32 fileCount)
{
    UNPKentry *entries = NULL;
    UNPKentry *entry = NULL;

    entries = (UNPKentry *) allocator.Malloc(sizeof (UNPKentry) * fileCount);
    BAIL_IF_MACRO(entries == NULL, PHYSFS_ERR_OUT_OF_MEMORY, NULL);

    for (entry = entries; fileCount > 0; fileCount--, entry++)
    {
        char *ptr;

        /* don't include the '\' in the beginning */
        char backslash;
        GOTO_IF_MACRO(!__PHYSFS_readAll(io, &backslash, 1), ERRPASS, failed);
        GOTO_IF_MACRO(backslash != '\\', ERRPASS, failed);

        /* read the rest of the buffer, 63 bytes */
        GOTO_IF_MACRO(!__PHYSFS_readAll(io, &entry->name, 63), ERRPASS, failed);
        entry->name[63] = '\0'; /* in case the name lacks the null terminator */

        /* convert backslashes */
        for (ptr = entry->name; *ptr; ptr++)
        {
            if (*ptr == '\\')
                *ptr = '/';
        } /* for */

        GOTO_IF_MACRO(!__PHYSFS_readAll(io, &entry->startPos, 4),
                      ERRPASS, failed);
        entry->startPos = PHYSFS_swapULE32(entry->startPos);

        GOTO_IF_MACRO(!__PHYSFS_readAll(io, &entry->size, 4), ERRPASS, failed);
        entry->size = PHYSFS_swapULE32(entry->size);
    } /* for */
    
    return entries;

failed:
    allocator.Free(entries);
    return NULL;

} /* slbLoadEntries */
开发者ID:Tulioh,项目名称:android-libs,代码行数:43,代码来源:archiver_slb.c

示例11: malloc

char *__PHYSFS_platformGetUserName(void)
{
    DWORD bufsize = 0;
    LPTSTR retval = NULL;

    if (GetUserName(NULL, &bufsize) == 0)  /* This SHOULD fail. */
    {
        retval = (LPTSTR) malloc(bufsize);
        BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
        if (GetUserName(retval, &bufsize) == 0)  /* ?! */
        {
            __PHYSFS_setError(win32strerror());
            free(retval);
            retval = NULL;
        } /* if */
    } /* if */

    return((char *) retval);
} /* __PHYSFS_platformGetUserName */
开发者ID:newerthcom,项目名称:savagerebirth,代码行数:19,代码来源:win32.c

示例12: mvl_load_entries

static int mvl_load_entries(const char *name, int forWriting, MVLinfo *info)
{
    void *fh = NULL;
    PHYSFS_uint32 fileCount;
    PHYSFS_uint32 location = 8;  /* sizeof sig. */
    MVLentry *entry;

    BAIL_IF_MACRO(!mvl_open(name, forWriting, &fh, &fileCount), NULL, 0);
    info->entryCount = fileCount;
    info->entries = (MVLentry *) allocator.Malloc(sizeof(MVLentry)*fileCount);
    if (info->entries == NULL)
    {
        __PHYSFS_platformClose(fh);
        BAIL_MACRO(ERR_OUT_OF_MEMORY, 0);
    } /* if */

    location += (17 * fileCount);

    for (entry = info->entries; fileCount > 0; fileCount--, entry++)
    {
        if (__PHYSFS_platformRead(fh, &entry->name, 13, 1) != 1)
        {
            __PHYSFS_platformClose(fh);
            return 0;
        } /* if */

        if (__PHYSFS_platformRead(fh, &entry->size, 4, 1) != 1)
        {
            __PHYSFS_platformClose(fh);
            return 0;
        } /* if */

        entry->size = PHYSFS_swapULE32(entry->size);
        entry->startPos = location;
        location += entry->size;
    } /* for */

    __PHYSFS_platformClose(fh);

    __PHYSFS_sort(info->entries, info->entryCount,
                  mvl_entry_cmp, mvl_entry_swap);
    return 1;
} /* mvl_load_entries */
开发者ID:AndroidAppList,项目名称:Android-Supertux,代码行数:43,代码来源:archiver_mvl.c

示例13: open

static void *doOpen(const char *filename, int mode)
{
    int fd;
    int *retval;
    errno = 0;

    fd = open(filename, mode, S_IRUSR | S_IWUSR);
    BAIL_IF_MACRO(fd < 0, strerror(errno), NULL);

    retval = (int *) malloc(sizeof (int));
    if (retval == NULL)
    {
        close(fd);
        BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
    } /* if */

    *retval = fd;
    return((void *) retval);
} /* doOpen */
开发者ID:jcubic,项目名称:ToME,代码行数:19,代码来源:posix.c

示例14: __PHYSFS_platformCvtToDependent

static FileHandle *doOpen(DirHandle *h, const char *name,
                          void *(*openFunc)(const char *filename),
                          int *fileExists, const FileFunctions *fileFuncs)
{
    char *f = __PHYSFS_platformCvtToDependent((char *)(h->opaque), name, NULL);
    void *rc;
    FileHandle *retval;

    BAIL_IF_MACRO(f == NULL, NULL, NULL);

    if (fileExists != NULL)
    {
        *fileExists = __PHYSFS_platformExists(f);
        if (!(*fileExists))
        {
            free(f);
            return(NULL);
        } /* if */
    } /* if */

    retval = (FileHandle *) malloc(sizeof (FileHandle));
    if (!retval)
    {
        free(f);
        BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
    } /* if */

    rc = openFunc(f);
    free(f);

    if (!rc)
    {
        free(retval);
        return(NULL);
    } /* if */

    retval->opaque = (void *) rc;
    retval->dirHandle = h;
    retval->funcs = fileFuncs;

    return(retval);
} /* doOpen */
开发者ID:UIKit0,项目名称:paragui,代码行数:42,代码来源:dir.c

示例15: determineUserDir

  /*
  * Try to make use of GetUserProfileDirectoryW(), which isn't available on
  *  some common variants of Win32. If we can't use this, we just punt and
  *  use the physfs base dir for the user dir, too.
  *
  * On success, module-scope variable (userDir) will have a pointer to
  *  a malloc()'d string of the user's profile dir, and a non-zero value is
  *  returned. If we can't determine the profile dir, (userDir) will
  *  be NULL, and zero is returned.
  */
static int determineUserDir(void)
{
	if (userDir != NULL)
		return(1);  /* already good to go. */

	const wchar_t* path = Windows::Storage::ApplicationData::Current->LocalFolder->Path->Data();
	wchar_t path2[1024];
	wcscpy_s(path2, path);
	wcscat_s(path2, L"\\");

	userDir = unicodeToUtf8Heap(path2);

	if (userDir == NULL)  /* couldn't get profile for some reason. */
	{
		/* Might just be a non-NT system; resort to the basedir. */
		userDir = getExePath();
		BAIL_IF_MACRO(userDir == NULL, NULL, 0); /* STILL failed?! */
	} /* if */

	return(1);  /* We made it: hit the showers. */
} /* determineUserDir */
开发者ID:ahrnbom,项目名称:physfs-uwp,代码行数:31,代码来源:winrt.cpp


注:本文中的BAIL_IF_MACRO函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。