本文整理汇总了C++中PR_Malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_Malloc函数的具体用法?C++ PR_Malloc怎么用?C++ PR_Malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_Malloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LCMapStringW
nsresult nsCollationWin::AllocateRawSortKey(int32_t strength,
const nsAString& stringIn, uint8_t** key, uint32_t* outLen)
{
int byteLen;
void *buffer;
nsresult res = NS_OK;
DWORD dwMapFlags = LCMAP_SORTKEY;
if (strength == kCollationCaseInSensitive)
dwMapFlags |= NORM_IGNORECASE;
byteLen = LCMapStringW(mLCID, dwMapFlags,
(LPCWSTR) PromiseFlatString(stringIn).get(),
-1, NULL, 0);
buffer = PR_Malloc(byteLen);
if (!buffer) {
res = NS_ERROR_OUT_OF_MEMORY;
} else {
*key = (uint8_t *)buffer;
*outLen = LCMapStringW(mLCID, dwMapFlags,
(LPCWSTR) PromiseFlatString(stringIn).get(),
-1, (LPWSTR) buffer, byteLen);
}
return res;
}
开发者ID:BrunoReX,项目名称:palemoon,代码行数:25,代码来源:nsCollationWin.cpp
示例2: OutputDebugStringA
static void OutputDebugStringA(const char* msg) {
int len = MultiByteToWideChar(CP_ACP, 0, msg, -1, 0, 0);
WCHAR *wMsg = (WCHAR *)PR_Malloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, msg, -1, wMsg, len);
OutputDebugStringW(wMsg);
PR_Free(wMsg);
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:7,代码来源:prlog.c
示例3: PR_Strdup
/*
//////////////////////////////////////////////////////////////////////////
*/
static char*
PR_Strdup(const char* str)
{
char *tmp = (char*) PR_Malloc(strlen(str)+1);
strcpy(tmp, str);
return tmp;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:10,代码来源:install.c
示例4: JSS_throwMsgPrErrArg
/***********************************************************************
**
** J S S _ t h r o w M s g P r E r r A r g
**
** Throw an exception in native code. You should return right after
** calling this function.
**
** throwableClassName is the name of the throwable you are throwing in
** JNI class name format (xxx/xx/xxx/xxx). It must not be NULL.
**
** message is the message parameter of the throwable. It must not be NULL.
** If you don't have a message, call JSS_throw.
**
** errCode is a PRErrorCode returned from PR_GetError().
**
** Example:
** JSS_throwMsg(env, ILLEGAL_ARGUMENT_EXCEPTION, PR_GetError());
** return -1;
*/
void
JSS_throwMsgPrErrArg(JNIEnv *env, char *throwableClassName, char *message,
PRErrorCode errCode)
{
const char *errStr = JSS_strerror(errCode);
char *msg = NULL;
int msgLen;
if( errStr == NULL ) {
errStr = "Unknown error";
}
msgLen = strlen(message) + strlen(errStr) + 40;
msg = PR_Malloc(msgLen);
if( msg == NULL ) {
JSS_throw(env, OUT_OF_MEMORY_ERROR);
goto finish;
}
PR_snprintf(msg, msgLen, "%s: (%ld) %s", message, errCode, errStr);
JSS_throwMsg(env, throwableClassName, msg);
finish:
if(msg != NULL) {
PR_Free(msg);
}
}
开发者ID:MarcusPianco,项目名称:PredictVulnerabilities-ChangeHistory,代码行数:46,代码来源:jssutil.c
示例5: JSS_ByteArrayToSECItem
/***********************************************************************
* J S S _ B y t e A r r a y T o S E C I t e m
*
* Copies the contents of a Java byte array into a new SECItem.
*
* byteArray
* A Java byte array. Must not be NULL.
* RETURNS
* A newly allocated SECItem, or NULL iff an exception was thrown.
*/
SECItem*
JSS_ByteArrayToSECItem(JNIEnv *env, jbyteArray byteArray)
{
SECItem *item = NULL;
PR_ASSERT(env!=NULL && byteArray!=NULL);
/* Create a new SECItem */
item = PR_NEW(SECItem);
if( item == NULL ) {
JSS_throw(env, OUT_OF_MEMORY_ERROR);
goto finish;
}
/* Setup the length, allocate the buffer */
item->len = (*env)->GetArrayLength(env, byteArray);
item->data = PR_Malloc(item->len);
/* copy the bytes from the byte array into the SECItem */
(*env)->GetByteArrayRegion(env, byteArray, 0, item->len,
(jbyte*)item->data);
if( (*env)->ExceptionOccurred(env) ) {
SECITEM_FreeItem(item, PR_TRUE /*freeit*/);
item = NULL;
}
finish:
return item;
}
开发者ID:MarcusPianco,项目名称:PredictVulnerabilities-ChangeHistory,代码行数:39,代码来源:jssutil.c
示例6: PR_Malloc
void nsMsgBodyHandler::StripHtml (nsCString &pBufInOut)
{
char *pBuf = (char*) PR_Malloc (pBufInOut.Length() + 1);
if (pBuf)
{
char *pWalk = pBuf;
char *pWalkInOut = (char *) pBufInOut.get();
bool inTag = false;
while (*pWalkInOut) // throw away everything inside < >
{
if (!inTag)
if (*pWalkInOut == '<')
inTag = PR_TRUE;
else
*pWalk++ = *pWalkInOut;
else
if (*pWalkInOut == '>')
inTag = PR_FALSE;
pWalkInOut++;
}
*pWalk = 0; // null terminator
pBufInOut.Adopt(pBuf);
}
}
开发者ID:mikeconley,项目名称:comm-central,代码行数:26,代码来源:nsMsgBodyHandler.cpp
示例7: strlen
//
// remember the name and series of a token in a particular slot.
// This is important because the name is no longer available when
// the token is removed. If listeners depended on this information,
// They would be out of luck. It also is a handy way of making sure
// we don't generate spurious insertion and removal events as the slot
// cycles through various states.
//
void
SmartCardMonitoringThread::SetTokenName(CK_SLOT_ID slotid,
const char *tokenName, PRUint32 series)
{
if (mHash) {
if (tokenName) {
int len = strlen(tokenName) + 1;
/* this must match the allocator used in
* PLHashAllocOps.freeEntry DefaultFreeEntry */
char *entry = (char *)PR_Malloc(len+sizeof(PRUint32));
if (entry) {
memcpy(entry,&series,sizeof(PRUint32));
memcpy(&entry[sizeof(PRUint32)],tokenName,len);
PL_HashTableAdd(mHash,(void *)slotid, entry); /* adopt */
return;
}
}
else {
// if tokenName was not provided, remove the old one (implicit delete)
PL_HashTableRemove(mHash,(void *)slotid);
}
}
}
开发者ID:vdt,项目名称:mozilla-central,代码行数:33,代码来源:nsSmartCardMonitor.cpp
示例8: _PR_MD_CREATE_THREAD
PRStatus
_PR_MD_CREATE_THREAD(PRThread *thread,
void (*start)(void *),
PRThreadPriority priority,
PRThreadScope scope,
PRThreadState state,
PRUint32 stackSize)
{
PARAMSTORE* params = PR_Malloc(sizeof(PARAMSTORE));
params->start = start;
params->thread = thread;
thread->md.handle = thread->id = (TID) _beginthread(ExcpStartFunc,
NULL,
thread->stack->stackSize,
params);
if(thread->md.handle == -1) {
return PR_FAILURE;
}
/*
* On OS/2, a thread is created with a thread priority of
* THREAD_PRIORITY_NORMAL
*/
if (priority != PR_PRIORITY_NORMAL) {
_PR_MD_SET_PRIORITY(&(thread->md), priority);
}
return PR_SUCCESS;
}
开发者ID:ppbao,项目名称:mozilla-os2,代码行数:30,代码来源:os2thred.c
示例9: OrderLoop
/**
* Called from PL_HashTableEnumerateEntries
* A pointer to a PRCList (circular linked list) is passed in.
* Once enumeration is complete, the PRCList will contain a lexically
* ordered list of a copy of the keys in the hash.
* The caller needs to free the copies
*/
static PRIntn OrderLoop(PLHashEntry *he, PRIntn index, void *arg)
{
PRCList *qp = (PRCList *)arg;
OrderedEntry_t *entry;
if (he != NULL) {
entry = (OrderedEntry_t *) PR_Malloc(sizeof(OrderedEntry_t));
entry->key = PL_strdup((char *) he->key);
if (index ==0) {
PR_APPEND_LINK((PRCList *)entry, qp);
return HT_ENUMERATE_NEXT;
}
PRCList *head = PR_LIST_HEAD(qp);
PRCList *next;
while (head != qp) {
OrderedEntry_t *current = (OrderedEntry_t *) head;
if (strcmp((char *) he->key, (char *) current->key) <=0)
break;
next = PR_NEXT_LINK(head);
head = next;
}
PR_INSERT_BEFORE((PRCList*) entry, head);
return HT_ENUMERATE_NEXT;
} else {
return HT_ENUMERATE_STOP;
}
}
开发者ID:encukou,项目名称:pki,代码行数:34,代码来源:ConfigStore.cpp
示例10: nsInstallObject
nsInstallUninstall::nsInstallUninstall( nsInstall* inInstall,
const nsString& regName,
PRInt32 *error)
: nsInstallObject(inInstall)
{
MOZ_COUNT_CTOR(nsInstallUninstall);
if (regName.IsEmpty())
{
*error = nsInstall::INVALID_ARGUMENTS;
return;
}
mRegName.Assign(regName);
char* userName = (char*)PR_Malloc(MAXREGPATHLEN);
PRInt32 err = VR_GetUninstallUserName( NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(regName).get()),
userName,
MAXREGPATHLEN );
mUIName.AssignWithConversion(userName);
if (err != REGERR_OK)
{
*error = nsInstall::NO_SUCH_COMPONENT;
}
PR_FREEIF(userName);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:31,代码来源:nsInstallUninstall.cpp
示例11: NS_ASSERTION
nsresult
nsSubscribableServer::CreateNode(SubscribeTreeNode *parent, const char *name, SubscribeTreeNode **result)
{
NS_ASSERTION(result && name, "result or name is null");
if (!result || !name) return NS_ERROR_NULL_POINTER;
*result = (SubscribeTreeNode *) PR_Malloc(sizeof(SubscribeTreeNode));
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
(*result)->name = strdup(name);
if (!(*result)->name) return NS_ERROR_OUT_OF_MEMORY;
(*result)->parent = parent;
(*result)->prevSibling = nullptr;
(*result)->nextSibling = nullptr;
(*result)->firstChild = nullptr;
(*result)->lastChild = nullptr;
(*result)->isSubscribed = false;
(*result)->isSubscribable = false;
#ifdef HAVE_SUBSCRIBE_DESCRIPTION
(*result)->description = nullptr;
#endif
#ifdef HAVE_SUBSCRIBE_MESSAGES
(*result)->messages = 0;
#endif
(*result)->cachedChild = nullptr;
if (parent) {
parent->cachedChild = *result;
}
return NS_OK;
}
开发者ID:ezagainov,项目名称:releases-comm-central,代码行数:33,代码来源:nsSubscribableServer.cpp
示例12: if
TPS_PUBLIC char *Util::URLEncode (Buffer &data)
{
int i;
BYTE *buf = (BYTE*)data;
int len = (int)data.size();
int sum = 0;
for (i = 0; i < len; i ++) {
if (buf[i] == ' ') {
sum+=1;
} else if (isAlphaNumeric(buf[i])) {
sum+=1;
} else {
sum+=3;
}
}
char *ret = (char *)PR_Malloc(sum + 1); // allocate more than we may need
char *cur = ret;
for (i = 0; i < len; i ++) {
if (buf[i] == ' ') {
*cur++ = '+';
} else if (isAlphaNumeric(buf[i])) {
*cur++ = buf[i];
} else {
*cur++ = '%';
*cur++ = bin2hex(buf[i] >> 4);
*cur++ = bin2hex(buf[i]);
}
}
*cur = '\0'; // null-terminated
return ret;
}
开发者ID:encukou,项目名称:pki,代码行数:33,代码来源:Util.cpp
示例13: DosQueryResourceSize
/* Returned string needs to be PR_Free'd by caller */
static char *LoadRCDATAString( HMODULE hMod, ULONG resid)
{
APIRET rc;
ULONG ulSize = 0;
char *string = 0;
rc = DosQueryResourceSize( hMod, RT_RCDATA, resid, &ulSize);
if( rc == NO_ERROR)
{
char *readOnlyString = 0;
rc = DosGetResource( hMod, RT_RCDATA, resid, (void**) &readOnlyString);
/* allow for 0-termination if user hasn't got it right */
if( readOnlyString[ ulSize - 1] != '\0')
ulSize++;
if( rc == NO_ERROR)
{
/* copy string & zero-terminate */
string = (char*) PR_Malloc( ulSize);
memcpy( string, readOnlyString, ulSize - 1);
string[ ulSize - 1] = '\0';
DosFreeResource( readOnlyString);
}
}
return string;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:31,代码来源:nsPluginsDirOS2.cpp
示例14: while
char *nsMsgSearchAdapter::TransformSpacesToStars (const char *spaceString, msg_TransformType transformType)
{
char *starString;
if (transformType == kOverwrite)
{
if ((starString = strdup(spaceString)) != nsnull)
{
char *star = starString;
while ((star = PL_strchr(star, ' ')) != nsnull)
*star = '*';
}
}
else
{
int i, count;
for (i = 0, count = 0; spaceString[i]; )
{
if (spaceString[i++] == ' ')
{
count++;
while (spaceString[i] && spaceString[i] == ' ') i++;
}
}
if (transformType == kSurround)
count *= 2;
if (count > 0)
{
if ((starString = (char *)PR_Malloc(i + count + 1)) != nsnull)
{
int j;
for (i = 0, j = 0; spaceString[i]; )
{
if (spaceString[i] == ' ')
{
starString[j++] = '*';
starString[j++] = ' ';
if (transformType == kSurround)
starString[j++] = '*';
i++;
while (spaceString[i] && spaceString[i] == ' ')
i++;
}
else
starString[j++] = spaceString[i++];
}
starString[j] = 0;
}
}
else
starString = strdup(spaceString);
}
return starString;
}
开发者ID:mikeconley,项目名称:comm-central,代码行数:60,代码来源:nsMsgSearchAdapter.cpp
示例15: NS_NewLocalFileInputStream
nsresult nsAutoConfig::evaluateLocalFile(nsIFile *file)
{
nsresult rv;
nsCOMPtr<nsIInputStream> inStr;
rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), file);
if (NS_FAILED(rv))
return rv;
PRInt64 fileSize;
PRUint32 fs, amt=0;
file->GetFileSize(&fileSize);
LL_L2UI(fs, fileSize); // Converting 64 bit structure to unsigned int
char *buf = (char *)PR_Malloc(fs * sizeof(char));
if (!buf)
return NS_ERROR_OUT_OF_MEMORY;
rv = inStr->Read(buf, fs, &amt);
if (NS_SUCCEEDED(rv)) {
EvaluateAdminConfigScript(buf, fs, nsnull, PR_FALSE,
PR_TRUE, PR_FALSE);
}
inStr->Close();
PR_Free(buf);
return rv;
}
开发者ID:typ4rk,项目名称:mozilla-history,代码行数:26,代码来源:nsAutoConfig.cpp
示例16: PatternLoop
/**
* Called from PL_HashTableEnumerateEntries
* A pointer to a PatternEntry is passed in. A PatternEntry consists of
* a pointer a regex_t and a pointer to a new config store.
* Once enumeration is complete, the new config store will contain
* all the parameters (key and values) whose keys match the regex.
*/
static PRIntn PatternLoop(PLHashEntry *he, PRIntn index, void *arg)
{
PatternEntry_t *entry = (PatternEntry_t *) arg;
if (entry == NULL) {
return HT_ENUMERATE_STOP;
}
regex_t *r = entry->regex;
ConfigStore *store = entry->store;
if ((r == NULL) || (store == NULL)) {
return HT_ENUMERATE_STOP;
}
size_t no_sub = r->re_nsub+1;
regmatch_t *result = NULL;
result = (regmatch_t *) PR_Malloc(sizeof(regmatch_t) * no_sub);
if ((he != NULL) && (he->key != NULL) && (he->value != NULL)) {
if (regexec(r, (char *) he->key, no_sub, result, 0)==0) {
// Found a match
store->Add((const char*) he->key, (const char *) he->value);
}
} else {
return HT_ENUMERATE_STOP;
}
if (result != NULL) PR_Free(result);
return HT_ENUMERATE_NEXT;
}
开发者ID:encukou,项目名称:pki,代码行数:39,代码来源:ConfigStore.cpp
示例17: PR_Malloc
char *nsMsgSearchAdapter::UnEscapeSearchUrl (const char *commandSpecificData)
{
char *result = (char*) PR_Malloc (strlen(commandSpecificData) + 1);
if (result)
{
char *resultPtr = result;
while (1)
{
char ch = *commandSpecificData++;
if (!ch)
break;
if (ch == '\\')
{
char scratchBuf[3];
scratchBuf[0] = (char) *commandSpecificData++;
scratchBuf[1] = (char) *commandSpecificData++;
scratchBuf[2] = '\0';
unsigned int accum = 0;
sscanf (scratchBuf, "%X", &accum);
*resultPtr++ = (char) accum;
}
else
*resultPtr++ = ch;
}
*resultPtr = '\0';
}
return result;
}
开发者ID:mikeconley,项目名称:comm-central,代码行数:28,代码来源:nsMsgSearchAdapter.cpp
示例18: LogClient
nsresult aptCoreTrace::Init(const char* sLock)
{
if (mCanLog) return NS_OK;
mLC = new LogClient();
if (!mLC)
return NS_ERROR_OUT_OF_MEMORY;
const char* logfifo = getenv("JAXERLOG_PIPENAME");
mLC->Init(logfifo, -1, sLock);
mLC->OpenPipeForWrite();
#ifdef _WIN32
mPid = GetCurrentProcessId();
#else
mPid = getpid();
#endif
mLoggerLock = PR_NewMonitor();
mBuf = (char *)PR_Malloc(0x8000);
mBufSize = 0x8000;
mCanLog = PR_TRUE;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch)
UpdatePrefSettings(prefBranch, nsnull);
return NS_OK;
}
开发者ID:aptana,项目名称:Jaxer,代码行数:31,代码来源:aptCoreTrace.cpp
示例19: strlen
TPS_PUBLIC Buffer *Util::URLDecode(const char *data)
{
int i;
Buffer buf;
Buffer *ret = NULL;
int len = strlen(data);
BYTE *tmp = NULL;
int sum = 0;
if (len == 0)
return NULL;
tmp = (BYTE *)PR_Malloc(len);
for (i = 0; i < len; i++) {
if (data[i] == '+') {
tmp[sum++] = ' ';
} else if (data[i] == '%') {
tmp[sum++] = (hex2bin(data[i+1]) << 4) + hex2bin(data[i+2]);
i+=2;
} else {
tmp[sum++] = (BYTE)data[i];
}
}
ret = new Buffer(tmp, sum);
if( tmp != NULL ) {
PR_Free( tmp );
tmp = NULL;
}
return ret;
}
开发者ID:encukou,项目名称:pki,代码行数:30,代码来源:Util.cpp
示例20: AllocateSolidColorFrame
static void AllocateSolidColorFrame(layers::PlanarYCbCrData& aData,
int aWidth, int aHeight,
int aY, int aCb, int aCr)
{
MOZ_ASSERT(!(aWidth&1));
MOZ_ASSERT(!(aHeight&1));
// Allocate a single frame with a solid color
int yLen = aWidth*aHeight;
int cbLen = yLen>>2;
int crLen = cbLen;
uint8_t* frame = (uint8_t*) PR_Malloc(yLen+cbLen+crLen);
memset(frame, aY, yLen);
memset(frame+yLen, aCb, cbLen);
memset(frame+yLen+cbLen, aCr, crLen);
aData.mYChannel = frame;
aData.mYSize = IntSize(aWidth, aHeight);
aData.mYStride = aWidth;
aData.mCbCrStride = aWidth>>1;
aData.mCbChannel = frame + yLen;
aData.mCrChannel = aData.mCbChannel + cbLen;
aData.mCbCrSize = IntSize(aWidth>>1, aHeight>>1);
aData.mPicX = 0;
aData.mPicY = 0;
aData.mPicSize = IntSize(aWidth, aHeight);
aData.mStereoMode = StereoMode::MONO;
}
开发者ID:CodeSpeaker,项目名称:gecko-dev,代码行数:27,代码来源:MediaEngineDefault.cpp
注:本文中的PR_Malloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论