本文整理汇总了C++中MALLOCVAR函数的典型用法代码示例。如果您正苦于以下问题:C++ MALLOCVAR函数的具体用法?C++ MALLOCVAR怎么用?C++ MALLOCVAR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MALLOCVAR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}