• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MALLOCVAR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: pamd_fill_create

struct fillobj *
pamd_fill_create(void) {

    fillobj * fillObjP;
    struct fillState * stateP;

    MALLOCVAR(fillObjP);
    if (fillObjP == NULL)
        pm_error("out of memory allocating a fillhandle");

    MALLOCVAR(stateP);
    if (stateP == NULL)
        pm_error("out of memory allocating a fillhandle");

    stateP->n = 0;
    stateP->size = SOME;
    MALLOCARRAY(stateP->coords, stateP->size);
    if (stateP->coords == NULL)
        pm_error("out of memory allocating a fillhandle");
    stateP->curedge = 0;

    fillObjP->stateP = stateP;
    
    /* Turn off line clipping. */
    /* UGGH! We must eliminate this global variable */
    oldclip = pamd_setlineclip(0);
    
    return fillObjP;
}
开发者ID:chneukirchen,项目名称:netpbm-mirror,代码行数:29,代码来源:libpamd.c


示例2: xmlrpc_lock_create_windows

struct lock *
xmlrpc_lock_create_windows(void) {

    struct lock * lockP;

    MALLOCVAR(lockP);

    if (lockP) {
        CRITICAL_SECTION * criticalSectionP;

        MALLOCVAR(criticalSectionP);

        if (criticalSectionP) {
            InitializeCriticalSection(criticalSectionP);

            lockP->implementationP = criticalSectionP;
            lockP->acquire = &acquire;
            lockP->release = &release;
            lockP->destroy = &destroy;
        } else {
            free(lockP);
            lockP = NULL;
        }
    }
    return lockP;
}
开发者ID:BlackPearl01,项目名称:quick-box,代码行数:26,代码来源:lock_windows.c


示例3: createPath

static void
createPath(const char * const pathText,
           style        const style,
           path **      const pathPP) {
/*----------------------------------------------------------------------------
   Create a path as described by a <path> element whose "style" attribute
   indicates style 'style' and whose "d" attribute indicates path data
   'pathText'.
-----------------------------------------------------------------------------*/
    bool error;
    path * pathP;
    
    MALLOCVAR(pathP);
    if (pathP == NULL)
        error = TRUE;
    else {
        pathP->style = style;

        pathP->pathText = strdup(pathText);
        if (pathP->pathText == NULL)
            error = TRUE;
        else {
            pathP->pathTextLength = strlen(pathP->pathText);

            error = FALSE;
        }
        if (error)
            free(pathP);
    }
    if (error )
        *pathPP = NULL;
    else
        *pathPP = pathP;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:34,代码来源:svgtopam.c


示例4: xmlrpc_server_info_new

xmlrpc_server_info *
xmlrpc_server_info_new(xmlrpc_env * const envP,
                       const char * const serverUrl) {
    
    xmlrpc_server_info * serverInfoP;

    XMLRPC_ASSERT_ENV_OK(envP);
    XMLRPC_ASSERT_PTR_OK(serverUrl);

    MALLOCVAR(serverInfoP);
    if (serverInfoP == NULL)
        xmlrpc_faultf(envP, "Couldn't allocate memory for xmlrpc_server_info");
    else {
        serverInfoP->serverUrl = strdup(serverUrl);
        if (serverInfoP->serverUrl == NULL)
            xmlrpc_faultf(envP, "Couldn't allocate memory for server URL");
        else {
            serverInfoP->allowedAuth.basic        = false;
            serverInfoP->allowedAuth.digest       = false;
            serverInfoP->allowedAuth.gssnegotiate = false;
            serverInfoP->allowedAuth.ntlm         = false;
            serverInfoP->userNamePw = NULL;
            serverInfoP->basicAuthHdrValue = NULL;
            if (envP->fault_occurred)
                xmlrpc_strfree(serverInfoP->serverUrl);
        }
        if (envP->fault_occurred)
            free(serverInfoP);
    }
    return serverInfoP;
}
开发者ID:BehnamEmamian,项目名称:openholdembot,代码行数:31,代码来源:xmlrpc_server_info.c


示例5: ppmd_read_font

void
ppmd_read_font(FILE *                        const ifP,
               const struct ppmd_font **     const fontPP) {

    unsigned int relativeCodePoint;
    struct ppmd_glyph * glyphTable;
    struct ppmd_font * fontP;

    MALLOCVAR(fontP);
    if (fontP == NULL)
        pm_error("Insufficient memory for font header");

    readFontHeader(ifP, &fontP->header);

    MALLOCARRAY(glyphTable, fontP->header.characterCount);
    if (glyphTable == NULL)
        pm_error("Insufficient memory to store %u characters",
                 fontP->header.characterCount);

    for (relativeCodePoint = 0;
         relativeCodePoint < fontP->header.characterCount;
         ++relativeCodePoint) {

        readCharacter(ifP, &glyphTable[relativeCodePoint]);
    }
    fontP->glyphTable = glyphTable;
    *fontPP = fontP;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:28,代码来源:ppmdfont.c


示例6: xmlrpc_methodCreate

void
xmlrpc_methodCreate(xmlrpc_env *           const envP,
                    xmlrpc_method1               methodFnType1,
                    xmlrpc_method2               methodFnType2,
                    void *                 const userData,
                    const char *           const signatureString,
                    const char *           const helpText,
                    xmlrpc_methodInfo **   const methodPP) {

    xmlrpc_methodInfo * methodP;

    XMLRPC_ASSERT_ENV_OK(envP);

    MALLOCVAR(methodP);

    if (methodP == NULL)
        xmlrpc_faultf(envP, "Unable to allocate storage for a method "
                      "descriptor");
    else {
        methodP->methodFnType1  = methodFnType1;
        methodP->methodFnType2  = methodFnType2;
        methodP->userData       = userData;
        methodP->helpText       = strdup(helpText);

        makeSignatureList(envP, signatureString, &methodP->signatureListP);

        if (envP->fault_occurred)
            free(methodP);

        *methodPP = methodP;
    }
}
开发者ID:jasonbourneh0810,项目名称:FreeSWITCH,代码行数:32,代码来源:method.c


示例7: createFileImage

static void
createFileImage(TFile **     const filePP,
                const char * const name,
                uint32_t     const attrib,
                bool         const createFile,
                bool *       const succeededP) {

    TFile * fileP;

    MALLOCVAR(fileP);
    if (fileP == NULL)
        *succeededP = FALSE;
    else {
        int rc;

        if (createFile)
            rc = open(name, attrib | O_CREAT, S_IWRITE | S_IREAD);
        else
            rc = open(name, attrib);

        if (rc < 0)
            *succeededP = FALSE;
        else {
            fileP->fd = rc;
            *succeededP = TRUE;
        }
        if (!*succeededP)
            free(fileP);
    }
    *filePP = fileP;
}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:31,代码来源:file.c


示例8: readICEntry

static IC_Entry 
readICEntry (void) 
{
    IC_Entry entry;

    MALLOCVAR(entry);

    if (entry == NULL)
        pm_error("Unable to allcoate memory for IC entry");

    entry->width         = readU1();
    entry->height        = readU1();
    entry->color_count   = readU1();
    entry->reserved      = readU1();
    entry->planes        = readU2();
    entry->bitcount      = readU2();
    entry->size_in_bytes = readU4();
    entry->file_offset   = readU4();
    entry->colors        = NULL;
    entry->ih            = NULL;
    entry->xorBitmap     = NULL;
    entry->andBitmap     = NULL;
    
    return entry;
}
开发者ID:jhbsz,项目名称:DIR-850L_A1,代码行数:25,代码来源:winicontoppm.c


示例9: createServer

static void
createServer(struct _TServer ** const srvPP,
             bool               const noAccept,
             TChanSwitch *      const chanSwitchP,
             bool               const userChanSwitch,
             unsigned short     const portNumber,             
             const char **      const errorP) {

    struct _TServer * srvP;

    MALLOCVAR(srvP);

    if (srvP == NULL) {
        xmlrpc_asprintf(errorP,
                        "Unable to allocate space for server descriptor");
    } else {
        setupTrace(srvP);

        srvP->terminationRequested = false;

        initChanSwitchStuff(srvP, noAccept, chanSwitchP, userChanSwitch,
                            portNumber, errorP);

        if (!*errorP) {
            srvP->builtinHandlerP = HandlerCreate();
            if (!srvP->builtinHandlerP)
                xmlrpc_asprintf(errorP, "Unable to allocate space for "
                                "builtin handler descriptor");
            else {
                srvP->defaultHandler   = HandlerDefaultBuiltin;
                srvP->defaultHandlerContext = srvP->builtinHandlerP;

                srvP->name             = strdup("unnamed");
                srvP->logfilename      = NULL;
                srvP->keepalivetimeout = 15;
                srvP->keepalivemaxconn = 30;
                srvP->timeout          = 15;
                srvP->advertise        = TRUE;
                srvP->useSigchld       = FALSE;
                srvP->uriHandlerStackSize = 0;
                srvP->maxConn          = 15;
                srvP->maxConnBacklog   = 15;
            
                initUnixStuff(srvP);

                ListInitAutoFree(&srvP->handlers);

                srvP->logfileisopen = FALSE;
                
                *errorP = NULL;

                if (*errorP)
                    HandlerDestroy(srvP->builtinHandlerP);
            }
        }        
        if (*errorP)
            free(srvP);
    }
    *srvPP = srvP;
}
开发者ID:BehnamEmamian,项目名称:openholdembot,代码行数:60,代码来源:server.c


示例10: disposeOfCommandTokens

static void
disposeOfCommandTokens(struct tokenSet * const tokenSetP,
                       struct script *   const scriptP) {

    /* We've got a whole command in 'tokenSet'.  Parse it into *scriptP
       and reset tokenSet to empty.
    */
    
    struct commandListElt * commandListEltP;
    
    MALLOCVAR(commandListEltP);
    if (commandListEltP == NULL)
        pm_error("Out of memory allocating command list element frame");

    parseDrawCommand(*tokenSetP, &commandListEltP->commandP);

    {
        unsigned int i;
        for (i = 0; i < tokenSetP->count; ++i)
            pm_strfree(tokenSetP->token[i]);
        tokenSetP->count = 0;
    }
    /* Put the list element for this command at the tail of the list */
    commandListEltP->nextP = NULL;
    if (scriptP->commandListTailP)
        scriptP->commandListTailP->nextP = commandListEltP;
    else
        scriptP->commandListHeadP = commandListEltP;

    scriptP->commandListTailP = commandListEltP;
}
开发者ID:chneukirchen,项目名称:netpbm-mirror,代码行数:31,代码来源:ppmdraw.c


示例11: SocketUnixCreate

void
SocketUnixCreate(TSocket ** const socketPP) {

    struct socketUnix * socketUnixP;

    MALLOCVAR(socketUnixP);

    if (socketUnixP) {
        int rc;
        rc = socket(AF_INET, SOCK_STREAM, 0);
        if (rc < 0)
            *socketPP = NULL;
        else {
            socketUnixP->fd = rc;
            socketUnixP->userSuppliedFd = FALSE;

            {
                int32_t n = 1;
                int rc;
                rc = setsockopt(socketUnixP->fd, SOL_SOCKET, SO_REUSEADDR,
                                (char*)&n, sizeof(n));
                if (rc < 0)
                    *socketPP = NULL;
                else
                    SocketCreate(&vtbl, socketUnixP, socketPP);
            }
            if (!*socketPP)
                close(socketUnixP->fd);
        }
        if (!*socketPP)
            free(socketUnixP);
    } else
        *socketPP = NULL;
}
开发者ID:Distrotech,项目名称:opensips,代码行数:34,代码来源:abyss_socket_unix.c


示例12: makeChannelFromSsl

static void
makeChannelFromSsl(SSL *         const sslP,
                   TChannel **   const channelPP,
                   const char ** const errorP) {

    struct channelOpenssl * channelOpensslP;

    MALLOCVAR(channelOpensslP);
    
    if (channelOpensslP == NULL)
        xmlrpc_asprintf(errorP, "Unable to allocate memory for OpenSSL "
                        "socket descriptor");
    else {
        TChannel * channelP;
        
        channelOpensslP->sslP = sslP;
        channelOpensslP->userSuppliedSsl = TRUE;
        
        /* This should be ok as far as I can tell */
        ChannelCreate(&channelVtbl, channelOpensslP, &channelP);
        
        if (channelP == NULL)
            xmlrpc_asprintf(errorP, "Unable to allocate memory for "
                            "channel descriptor.");
        else {
            *channelPP = channelP;
            *errorP = NULL;
        }
        if (*errorP)
            free(channelOpensslP);
    }
}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:32,代码来源:socket_openssl.c


示例13: xmlrpc_datetime_new

xmlrpc_value *
xmlrpc_datetime_new(xmlrpc_env *const envP,
                    xmlrpc_datetime const dt) {

    xmlrpc_value *valP;

    const char **readBufferP;

    MALLOCVAR(readBufferP);

    if (!readBufferP)
        xmlrpc_faultf(envP, "Couldn't get memory for the cache part of the "
                "XML-RPC datetime value object");

    else {
        *readBufferP = NULL;

        xmlrpc_createXmlrpcValue(envP, &valP);

        if (!envP->fault_occurred) {
            valP->_type = XMLRPC_TYPE_DATETIME;

            valP->_value.dt = dt;

            valP->_cache = readBufferP;
        }
        if (envP->fault_occurred)
            free(readBufferP);
    }
    return valP;
}
开发者ID:arssivka,项目名称:naomech,代码行数:31,代码来源:xmlrpc_datetime.c


示例14: curlMulti_create

curlMulti *
curlMulti_create(void) {

    curlMulti * retval;
    curlMulti * curlMultiP;

    MALLOCVAR(curlMultiP);

    if (curlMultiP == NULL)
        retval = NULL;
    else {
        curlMultiP->lockP = xmlrpc_lock_create();

        if (curlMultiP->lockP == NULL)
            retval = NULL;
        else {
            curlMultiP->curlMultiP = curl_multi_init();
            if (curlMultiP->curlMultiP == NULL)
                retval = NULL;
            else
                retval = curlMultiP;

            if (retval == NULL)
                curlMultiP->lockP->destroy(curlMultiP->lockP);
        }
        if (retval == NULL)
            free(curlMultiP);
    }
    return retval;
}
开发者ID:BlackPearl01,项目名称:quick-box,代码行数:30,代码来源:curlmulti.c


示例15: dsCreateSource

struct sourceManager * 
dsCreateSource(const char * const fileName) {

    struct sourceManager * srcP;

    MALLOCVAR(srcP);
    if (srcP == NULL)
        pm_error("Unable to get memory for the Jpeg library source manager.");

    srcP->ifP = pm_openr(fileName);

    srcP->jpegSourceMgr.init_source = dsInitSource;
    srcP->jpegSourceMgr.fill_input_buffer = dsFillInputBuffer;
    srcP->jpegSourceMgr.skip_input_data = dsSkipInputData;
    srcP->jpegSourceMgr.resync_to_restart = jpeg_resync_to_restart;
    srcP->jpegSourceMgr.term_source = dsTermSource;
    
    srcP->prematureEof = FALSE;
    srcP->currentBuffer = srcP->buffer1;
    srcP->nextBuffer = srcP->buffer2;
    srcP->jpegSourceMgr.bytes_in_buffer = 
        fread(srcP->currentBuffer, 1, BUFFER_SIZE, srcP->ifP);
    srcP->jpegSourceMgr.next_input_byte = srcP->currentBuffer;
    srcP->bytesInNextBuffer = 
        fread(srcP->nextBuffer, 1, BUFFER_SIZE, srcP->ifP);

    return srcP;
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:28,代码来源:jpegdatasource.c


示例16: readInfoHeader

static IC_InfoHeader 
readInfoHeader (IC_Entry entry) 
{
    IC_InfoHeader ih;

    MALLOCVAR(ih);
    
    if (ih == NULL)
        pm_error("Unable to allocate memory for info header");

    ih->size            = readU4();
    ih->width           = readU4();
    ih->height          = readU4();
    ih->planes          = readU2();
    ih->bitcount        = readU2();
    ih->compression     = readU4();
    ih->imagesize       = readU4();
    ih->x_pixels_per_m  = readU4();
    ih->y_pixels_per_m  = readU4();
    ih->colors_used     = readU4();
    ih->colors_important = readU4();
    
    if (!entry->bitcount) entry->bitcount = ih->bitcount;
    if (entry->color_count == 0 && 
        entry->bitcount <= 8) entry->color_count = 256;
    if (ih->compression) {
        pm_error("Can't handle compressed icons");
    }
    return ih;
}
开发者ID:jhbsz,项目名称:DIR-850L_A1,代码行数:30,代码来源:winicontoppm.c


示例17: allocateFi

static ppm_fs_info *
allocateFi(int const cols) {

    ppm_fs_info * fi;

    MALLOCVAR(fi);
    
    if (fi != NULL) {
        MALLOCARRAY(fi->thisrederr  , cols + 2);
        MALLOCARRAY(fi->thisgreenerr, cols + 2);
        MALLOCARRAY(fi->thisblueerr , cols + 2);
        MALLOCARRAY(fi->nextrederr  , cols + 2);
        MALLOCARRAY(fi->nextgreenerr, cols + 2);
        MALLOCARRAY(fi->nextblueerr , cols + 2);
        
        if (fi->thisrederr   == NULL || 
            fi->thisgreenerr == NULL || 
            fi->thisblueerr  == NULL ||
            fi->nextrederr   == NULL || 
            fi->nextgreenerr == NULL || 
            fi->nextblueerr  == NULL)
            pm_error("out of memory allocating "
                     "Floyd-Steinberg control structure");
    } else
        pm_error("out of memory allocating Floyd-Steinberg control structure");

    return(fi);
}
开发者ID:Eleanor66613,项目名称:CS131,代码行数:28,代码来源:libppmfloyd.c


示例18: ThreadCreate

void
ThreadCreate(TThread **      const threadPP,
             void *          const userHandle,
             TThreadProc   * const func,
             TThreadDoneFn * const threadDone,
             bool            const useSigchld,
             size_t          const stackSize,
             const char **   const errorP) {
    
    TThread * threadP;

    MALLOCVAR(threadP);
    if (threadP == NULL)
        xmlrpc_asprintf(errorP,
                        "Can't allocate memory for thread descriptor.");
    else {
        sigset_t oldBlockedSet;
        pid_t rc;

        threadP->nextInPoolP = NULL;
        threadP->threadDone  = threadDone;
        threadP->userHandle  = userHandle;
        threadP->useSigchld  = useSigchld;
        threadP->pid         = 0;

        /* We have to be sure we don't get the SIGCHLD for this child's
           death until the child is properly registered in the thread pool
           so that the handler will know who he is.
        */
        blockSignalClass(SIGCHLD, &oldBlockedSet);

        rc = fork();
        
        if (rc < 0)
            xmlrpc_asprintf(errorP, "fork() failed, errno=%d (%s)",
                            errno, strerror(errno));
        else if (rc == 0) {
            /* This is the child */
            (*func)(userHandle);
            /* Note that thread cleanup (threadDone) is done by the _parent_,
               upon seeing our exit.
            */
            exit(0);
        } else {
            /* This is the parent */
            threadP->pid = rc;

            addToPool(threadP);

            sigprocmask(SIG_SETMASK, &oldBlockedSet, NULL);  /* restore */

            *errorP = NULL;
            *threadPP = threadP;
        }
        if (*errorP) {
            removeFromPool(threadP);
            free(threadP);
        }
    }
}
开发者ID:BlackPearl01,项目名称:quick-box,代码行数:60,代码来源:thread_fork.c


示例19: makeChannelFromWinsock

static void
makeChannelFromWinsock(SOCKET        const winsock,
                       TChannel **   const channelPP,
                       const char ** const errorP) {

    struct socketWin * socketWinP;

    MALLOCVAR(socketWinP);
    
    if (socketWinP == NULL)
        xmlrpc_asprintf(errorP, "Unable to allocate memory for Windows "
                        "socket descriptor");
    else {
        TChannel * channelP;
        
        socketWinP->winsock = winsock;
        socketWinP->userSuppliedWinsock = TRUE;
        socketWinP->interruptEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

        ChannelCreate(&channelVtbl, socketWinP, &channelP);
        
        if (channelP == NULL)
            xmlrpc_asprintf(errorP, "Unable to allocate memory for "
                            "channel descriptor.");
        else {
            *channelPP = channelP;
            *errorP = NULL;
        }
        if (*errorP) {
            CloseHandle(socketWinP->interruptEvent);
            free(socketWinP);
        }
    }
}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:34,代码来源:socket_win.c


示例20: ChanSwitchWinCreateWinsock

void
ChanSwitchWinCreateWinsock(SOCKET         const winsock,
                           TChanSwitch ** const chanSwitchPP,
                           const char **  const errorP) {

    struct socketWin * socketWinP;

    if (connected(winsock))
        xmlrpc_asprintf(errorP, "Socket is in connected state.");
    else {
        MALLOCVAR(socketWinP);

        if (socketWinP == NULL)
            xmlrpc_asprintf(errorP, "unable to allocate memory for Windows "
                            "socket descriptor.");
        else {
            TChanSwitch * chanSwitchP;

            socketWinP->winsock = winsock;
            socketWinP->userSuppliedWinsock = TRUE;
            
            ChanSwitchCreate(&chanSwitchVtbl, socketWinP, &chanSwitchP);

            if (chanSwitchP == NULL)
                xmlrpc_asprintf(errorP, "Unable to allocate memory for "
                                "channel switch descriptor");
            else {
                *chanSwitchPP = chanSwitchP;
                *errorP = NULL;
            }
            if (*errorP)
                free(socketWinP);
        }
    }
}
开发者ID:ssc3,项目名称:multi-xml-rpc,代码行数:35,代码来源:socket_win.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MALLOC_CHECK函数代码示例发布时间:2022-05-30
下一篇:
C++ MALLOCATE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap