本文整理汇总了C++中PR_MALLOC函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_MALLOC函数的具体用法?C++ PR_MALLOC怎么用?C++ PR_MALLOC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_MALLOC函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MimeInlineTextVCard_parse_line
static int
MimeInlineTextVCard_parse_line (const char *line, int32_t length, MimeObject *obj)
{
// This routine gets fed each line of data, one at a time.
char* linestring;
MimeInlineTextVCardClass *clazz = ((MimeInlineTextVCardClass *) obj->clazz);
if (!obj->output_p) return 0;
if (!obj->options || !obj->options->output_fn) return 0;
if (!obj->options->write_html_p)
{
return COM_MimeObject_write(obj, line, length, true);
}
linestring = (char *) PR_MALLOC (length + 1);
memset(linestring, 0, (length + 1));
if (linestring)
{
strcpySafe((char *)linestring, line, length + 1);
NS_MsgSACat (&clazz->vCardString, linestring);
PR_Free (linestring);
}
return 0;
}
开发者ID:SphereWeb,项目名称:releases-comm-central,代码行数:26,代码来源:mimevcrd.cpp
示例2: MimeUntypedText_yenc_begin_line_p
static bool MimeUntypedText_yenc_begin_line_p(const char *line, int32_t length,
MimeDisplayOptions *opt,
char **type_ret,
char **name_ret) {
const char *s;
const char *endofline = line + length;
char *name = 0;
char *type = 0;
if (type_ret) *type_ret = 0;
if (name_ret) *name_ret = 0;
/* we don't support yenc V2 neither multipart yencode,
therefore the second parameter should always be "line="*/
if (length < 13 || strncmp(line, "=ybegin line=", 13)) return false;
/* ...then couple digits. */
for (s = line + 13; s < endofline; s++)
if (*s < '0' || *s > '9') break;
/* ...next, look for <space>size= */
if ((endofline - s) < 6 || strncmp(s, " size=", 6)) return false;
/* ...then couple digits. */
for (s += 6; s < endofline; s++)
if (*s < '0' || *s > '9') break;
/* ...next, look for <space>name= */
if ((endofline - s) < 6 || strncmp(s, " name=", 6)) return false;
/* anything left is the file name */
s += 6;
name = (char *)PR_MALLOC((endofline - s) + 1);
if (!name) return false; /* grr... */
memcpy(name, s, endofline - s);
name[endofline - s] = 0;
/* take off newline. */
if (name[strlen(name) - 1] == '\n') name[strlen(name) - 1] = 0;
if (name[strlen(name) - 1] == '\r') name[strlen(name) - 1] = 0;
/* Now try and figure out a type.
*/
if (opt && opt->file_type_fn)
type = opt->file_type_fn(name, opt->stream_closure);
else
type = 0;
if (name_ret)
*name_ret = name;
else
PR_FREEIF(name);
if (type_ret)
*type_ret = type;
else
PR_FREEIF(type);
return true;
}
开发者ID:mozilla,项目名称:releases-comm-central,代码行数:60,代码来源:mimeunty.cpp
示例3: PR_MALLOC
nsresult
RDFContentSinkImpl::AddText(const PRUnichar* aText, PRInt32 aLength)
{
// Create buffer when we first need it
if (0 == mTextSize) {
mText = (PRUnichar *) PR_MALLOC(sizeof(PRUnichar) * 4096);
if (!mText) {
return NS_ERROR_OUT_OF_MEMORY;
}
mTextSize = 4096;
}
// Copy data from string into our buffer; grow the buffer as needed.
// It never shrinks, but since the content sink doesn't stick around,
// this shouldn't be a bloat issue.
PRInt32 amount = mTextSize - mTextLength;
if (amount < aLength) {
// Grow the buffer by at least a factor of two to prevent thrashing.
// Since PR_REALLOC will leave mText intact if the call fails,
// don't clobber mText or mTextSize until the new mem is allocated.
PRInt32 newSize = (2 * mTextSize > (mTextSize + aLength)) ?
(2 * mTextSize) : (mTextSize + aLength);
PRUnichar* newText =
(PRUnichar *) PR_REALLOC(mText, sizeof(PRUnichar) * newSize);
if (!newText)
return NS_ERROR_OUT_OF_MEMORY;
mTextSize = newSize;
mText = newText;
}
memcpy(&mText[mTextLength], aText, sizeof(PRUnichar) * aLength);
mTextLength += aLength;
return NS_OK;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:34,代码来源:nsRDFContentSink.cpp
示例4: FilterWithoutEnglishLetters
//This filter apply to all scripts that does not use latin letters (english letter)
PRBool SBCSGroupProber::FilterWithoutEnglishLetters(const char* aBuf, PRUint32 aLen, char** newBuf, PRUint32& newLen)
{
//do filtering to reduce load to probers
char *newptr;
char *prevPtr, *curPtr;
PRBool meetMSB = PR_FALSE;
newptr = *newBuf = (char*)PR_MALLOC(aLen);
if (!newptr)
return PR_FALSE;
for (curPtr = prevPtr = (char*)aBuf; curPtr < aBuf+aLen; curPtr++)
{
if (*curPtr & 0x80)
meetMSB = PR_TRUE;
else if (*curPtr < 'A' || (*curPtr > 'Z' && *curPtr < 'a') || *curPtr > 'z')
{
//current char is a symbol, most likely a punctuation. we treat it as segment delimiter
if (meetMSB && curPtr > prevPtr)
//this segment contains more than single symbol, and it has upper ascii, we need to keep it
{
while (prevPtr < curPtr) *newptr++ = *prevPtr++;
prevPtr++;
*newptr++ = ' ';
meetMSB = PR_FALSE;
}
else //ignore current segment. (either because it is just a symbol or just a english word
prevPtr = curPtr+1;
}
}
newLen = newptr - *newBuf;
return PR_TRUE;
}
开发者ID:yaoweibin,项目名称:libcharguess,代码行数:36,代码来源:SBCSGroupProber.cpp
示例5: assembleCmdLine
/*
* Assemble the command line by concatenating the argv array.
* Special characters intentionally do not get escaped, and it is
* expected that the caller wraps arguments in quotes if needed
* (e.g. for filename with spaces).
*
* On success, this function returns 0 and the resulting command
* line is returned in *cmdLine. On failure, it returns -1.
*/
static int assembleCmdLine(char *const *argv, char **cmdLine)
{
char *const *arg;
int cmdLineSize;
/*
* Find out how large the command line buffer should be.
*/
cmdLineSize = 1; /* final null */
for (arg = argv+1; *arg; arg++) {
cmdLineSize += strlen(*arg) + 1; /* space in between */
}
*cmdLine = PR_MALLOC(cmdLineSize);
if (*cmdLine == NULL) {
return -1;
}
(*cmdLine)[0] = '\0';
for (arg = argv+1; *arg; arg++) {
if (arg > argv +1) {
strcat(*cmdLine, " ");
}
strcat(*cmdLine, *arg);
}
return 0;
}
开发者ID:ppbao,项目名称:mozilla-os2,代码行数:36,代码来源:os2misc.c
示例6: return
/* binary block Allocate and Concatenate
*
* destination_length is the length of the existing block
* source_length is the length of the block being added to the
* destination block
*/
static char *il_BACat (char **destination,
size_t destination_length,
const char *source,
size_t source_length)
{
if (source) {
if (*destination) {
*destination = (char *) PR_REALLOC (*destination,
destination_length + source_length);
if (*destination == nsnull)
return (nsnull);
memmove(*destination + destination_length, source, source_length);
}
else {
*destination = (char *) PR_MALLOC (source_length);
if (*destination == nsnull)
return (nsnull);
memcpy(*destination, source, source_length);
}
}
return *destination;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:31,代码来源:GIF2.cpp
示例7: MimeHeaders_copy
MimeHeaders *
MimeHeaders_copy (MimeHeaders *hdrs)
{
MimeHeaders *hdrs2;
if (!hdrs) return 0;
hdrs2 = (MimeHeaders *) PR_MALLOC(sizeof(*hdrs));
if (!hdrs2) return 0;
memset(hdrs2, 0, sizeof(*hdrs2));
if (hdrs->all_headers)
{
hdrs2->all_headers = (char *) PR_MALLOC(hdrs->all_headers_fp);
if (!hdrs2->all_headers)
{
PR_Free(hdrs2);
return 0;
}
memcpy(hdrs2->all_headers, hdrs->all_headers, hdrs->all_headers_fp);
hdrs2->all_headers_fp = hdrs->all_headers_fp;
hdrs2->all_headers_size = hdrs->all_headers_fp;
}
hdrs2->done_p = hdrs->done_p;
if (hdrs->heads)
{
int i;
hdrs2->heads = (char **) PR_MALLOC(hdrs->heads_size
* sizeof(*hdrs->heads));
if (!hdrs2->heads)
{
PR_FREEIF(hdrs2->all_headers);
PR_Free(hdrs2);
return 0;
}
hdrs2->heads_size = hdrs->heads_size;
for (i = 0; i < hdrs->heads_size; i++)
{
hdrs2->heads[i] = (hdrs2->all_headers +
(hdrs->heads[i] - hdrs->all_headers));
}
}
return hdrs2;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:46,代码来源:mimehdrs.cpp
示例8: DefaultAllocTable
/*
** Stubs for default hash allocator ops.
*/
static void * PR_CALLBACK
DefaultAllocTable(void *pool, PRSize size)
{
#if defined(XP_MAC)
#pragma unused (pool)
#endif
return PR_MALLOC(size);
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:12,代码来源:plhash.c
示例9: MimeUntypedText_uu_begin_line_p
static bool MimeUntypedText_uu_begin_line_p(const char *line, int32_t length,
MimeDisplayOptions *opt,
char **type_ret, char **name_ret) {
const char *s;
char *name = 0;
char *type = 0;
if (type_ret) *type_ret = 0;
if (name_ret) *name_ret = 0;
if (strncmp(line, "begin ", 6)) return false;
/* ...then three or four octal digits. */
s = line + 6;
if (*s < '0' || *s > '7') return false;
s++;
if (*s < '0' || *s > '7') return false;
s++;
if (*s < '0' || *s > '7') return false;
s++;
if (*s == ' ')
s++;
else {
if (*s < '0' || *s > '7') return false;
s++;
if (*s != ' ') return false;
}
while (IS_SPACE(*s)) s++;
name = (char *)PR_MALLOC(((line + length) - s) + 1);
if (!name) return false; /* grr... */
memcpy(name, s, (line + length) - s);
name[(line + length) - s] = 0;
/* take off newline. */
if (name[strlen(name) - 1] == '\n') name[strlen(name) - 1] = 0;
if (name[strlen(name) - 1] == '\r') name[strlen(name) - 1] = 0;
/* Now try and figure out a type.
*/
if (opt && opt->file_type_fn)
type = opt->file_type_fn(name, opt->stream_closure);
else
type = 0;
if (name_ret)
*name_ret = name;
else
PR_FREEIF(name);
if (type_ret)
*type_ret = type;
else
PR_FREEIF(type);
return true;
}
开发者ID:mozilla,项目名称:releases-comm-central,代码行数:57,代码来源:mimeunty.cpp
示例10: _pr_context_create
pr_context* _pr_context_create(const PRcontextdesc* desc, PRuint width, PRuint height)
{
if (desc == NULL || desc->window == NULL || width <= 0 || height <= 0)
{
_pr_error_set(PR_ERROR_INVALID_ARGUMENT, __FUNCTION__);
return NULL;
}
// Create render context
pr_context* context = PR_MALLOC(pr_context);
// Setup bitmap info structure
BITMAPINFO* bmi = (&context->bmpInfo);
memset(bmi, 0, sizeof(BITMAPINFO));
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi->bmiHeader.biWidth = (LONG)width;
bmi->bmiHeader.biHeight = (LONG)height;
bmi->bmiHeader.biPlanes = 1;
bmi->bmiHeader.biBitCount = 24;
bmi->bmiHeader.biCompression = BI_RGB;
// Setup context
context->wnd = *((HWND*)desc->window);
context->dc = GetDC(context->wnd);
context->dcBmp = CreateCompatibleDC(context->dc);
context->bmp = CreateCompatibleBitmap(context->dc, width, height);
context->colors = PR_CALLOC(pr_color, width*height);
context->width = width;
context->height = height;
SelectObject(context->dcBmp, context->bmp);
// Create color palette
context->colorPalette = PR_MALLOC(pr_color_palette);
_pr_color_palette_fill_r3g3b2(context->colorPalette);
// Initialize state machine
_pr_state_machine_init(&(context->stateMachine));
_pr_context_makecurrent(context);
return context;
}
开发者ID:LukasBanana,项目名称:PicoRenderer,代码行数:43,代码来源:context.c
示例11: MimePgpe_generate
static char*
MimePgpe_generate(void *output_closure)
{
const char htmlMsg[] = "<html><body><b>GEN MSG<b></body></html>";
char* msg = (char *) PR_MALLOC(strlen(htmlMsg) + 1);
if (msg)
PL_strcpy(msg, htmlMsg);
return msg;
}
开发者ID:cmotc,项目名称:spacehamster,代码行数:10,代码来源:nsPgpMimeProxy.cpp
示例12: _pr_vertexbuffer_create
pr_vertexbuffer* _pr_vertexbuffer_create()
{
pr_vertexbuffer* vertexBuffer = PR_MALLOC(pr_vertexbuffer);
vertexBuffer->numVertices = 0;
vertexBuffer->vertices = NULL;
_pr_ref_add(vertexBuffer);
return vertexBuffer;
}
开发者ID:LukasBanana,项目名称:PicoRenderer,代码行数:11,代码来源:vertexbuffer.c
示例13: MimeHeaders_new
MimeHeaders *
MimeHeaders_new (void)
{
MimeHeaders *hdrs = (MimeHeaders *) PR_MALLOC(sizeof(MimeHeaders));
if (!hdrs) return 0;
memset(hdrs, 0, sizeof(*hdrs));
hdrs->done_p = false;
return hdrs;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:11,代码来源:mimehdrs.cpp
示例14: PR_IMPLEMENT
PR_IMPLEMENT(void) PR_SetLogBuffering(PRIntn buffer_size)
{
PR_LogFlush();
if (logBuf)
PR_DELETE(logBuf);
if (buffer_size >= LINE_BUF_SIZE) {
logp = logBuf = (char*) PR_MALLOC(buffer_size);
logEndp = logp + buffer_size;
}
}
开发者ID:SeanLiangYoung,项目名称:nocnnic,代码行数:12,代码来源:prlog.c
示例15: getPRErrorText
// Release the retun value with PR_FREEIF
static char* getPRErrorText ()
{
PRInt32 errTextLen = PR_GetErrorTextLength ();
char *s = (char*)PR_MALLOC (errTextLen + 1);
if (s)
{
s[0] = '\0';
(void)PR_GetErrorText (s);
}
return s;
}
开发者ID:AtomLaw,项目名称:webcl-firefox,代码行数:13,代码来源:WebCL_libcl.cpp
示例16: getPRErrorText
// Release the retun value with PR_FREEIF
static char* getPRErrorText ()
{
PRInt32 errTextLen = PR_GetErrorTextLength ();
char *rv = (char*)PR_MALLOC (errTextLen + 1);
if (rv)
{
rv[0] = '\0';
(void)PR_GetErrorText (rv);
}
return rv;
}
开发者ID:ameyapg,项目名称:webcl-firefox,代码行数:13,代码来源:WebCL_libcl.cpp
示例17: MimeEnig_generate
static char*
MimeEnig_generate(void *output_closure)
{
fprintf(stderr, "MimeEnig_generate:\n");
const char htmlMsg[] = "<html><body><b>GEN MSG<b></body></html>";
char* msg = (char *) PR_MALLOC(strlen(htmlMsg) + 1);
if (msg) {
PL_strcpy(msg, htmlMsg);
}
return msg;
}
开发者ID:imudak,项目名称:enigmail,代码行数:12,代码来源:mimeenig.cpp
示例18: PR_ProcessAttrSetCurrentDirectory
PR_ProcessAttrSetCurrentDirectory(
PRProcessAttr *attr,
const char *dir)
{
PR_FREEIF(attr->currentDirectory);
attr->currentDirectory = (char *) PR_MALLOC(strlen(dir) + 1);
if (!attr->currentDirectory) {
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
return PR_FAILURE;
}
strcpy(attr->currentDirectory, dir);
return PR_SUCCESS;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:13,代码来源:prinit.c
示例19: _MD_EarlyInit
void _MD_EarlyInit(void)
{
#ifndef _PR_PTHREADS
/*
* The following piece of code is taken from ns/nspr/src/md_HP-UX.c.
* In the comment for revision 1.6, dated 1995/09/11 23:33:34,
* robm says:
* This version has some problems which need to be addressed.
* First, intercept all system calls and prevent them from
* executing the library code which performs stack switches
* before normal system call invocation. In order for library
* calls which make system calls to work (like stdio), however,
* we must also allocate our own stack and switch the primordial
* stack to use it. This isn't so bad, except that I fudged the
* backtrace length when copying the old stack to the new one.
*
* This is the original comment of robm in the code:
* XXXrobm Horrific. To avoid a problem with HP's system call
* code, we allocate a new stack for the primordial thread and
* use it. However, we don't know how far back the original stack
* goes. We should create a routine that performs a backtrace and
* finds out just how much we need to copy. As a temporary measure,
* I just copy an arbitrary guess.
*
* In an email to servereng dated 2 Jan 1997, Mike Patnode (mikep)
* suggests that this only needs to be done for HP-UX 9.
*/
#ifdef HPUX9
#define PIDOOMA_STACK_SIZE 524288
#define BACKTRACE_SIZE 8192
{
jmp_buf jb;
char *newstack;
char *oldstack;
if(!setjmp(jb)) {
newstack = (char *) PR_MALLOC(PIDOOMA_STACK_SIZE);
oldstack = (char *) (*(((int *) jb) + 1) - BACKTRACE_SIZE);
memcpy(newstack, oldstack, BACKTRACE_SIZE);
*(((int *) jb) + 1) = (int) (newstack + BACKTRACE_SIZE);
longjmp(jb, 1);
}
}
#endif /* HPUX9 */
#endif /* !_PR_PTHREADS */
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.external,代码行数:46,代码来源:hpux.c
示例20: push_tag
static int
push_tag(MimeMultipartRelated* relobj, const char* buf, int32_t size)
{
if (size + relobj->curtag_length > relobj->curtag_max) {
relobj->curtag_max += 2 * size;
if (relobj->curtag_max < 1024) relobj->curtag_max = 1024;
if (!relobj->curtag) {
relobj->curtag = (char*) PR_MALLOC(relobj->curtag_max);
} else {
relobj->curtag = (char*) PR_Realloc(relobj->curtag,
relobj->curtag_max);
}
if (!relobj->curtag) return MIME_OUT_OF_MEMORY;
}
memcpy(relobj->curtag + relobj->curtag_length, buf, size);
relobj->curtag_length += size;
return 0;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:18,代码来源:mimemrel.cpp
注:本文中的PR_MALLOC函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论