本文整理汇总了C++中FskMemPtrNew函数的典型用法代码示例。如果您正苦于以下问题:C++ FskMemPtrNew函数的具体用法?C++ FskMemPtrNew怎么用?C++ FskMemPtrNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FskMemPtrNew函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xs_mod_init
void
xs_mod_init(xsMachine *the)
{
mod_t *mod;
UInt32 options = xsToInteger(xsArgc) > 0 && xsTypeOf(xsArg(0)) == xsIntegerType ? xsToInteger(xsArg(0)): 0;
FskErr ferr;
if ((ferr = FskMemPtrNew(sizeof(mod_t), (FskMemPtr *)&mod)) != kFskErrNone)
cryptThrowFSK(ferr);
if ((ferr = FskMemPtrNew(sizeof(bn_mod_t), (FskMemPtr *)&mod->mod_data)) != kFskErrNone) {
FskMemPtrDispose(mod);
cryptThrowFSK(ferr);
}
mod->_mod_code = &modFuncs;
xsResult = xsGet(xsThis, xsID("z")); /* must exist */
if (!xsIsInstanceOf(xsResult, xsGet(xsGet(xsGlobal, xsID("Arith")), xsID("z"))) || (mod->z = xsGetHostData(xsResult)) == NULL)
cryptThrow("kCryptTypeError");
xsResult = xsGet(xsThis, xsID("m")); /* must exist */
if (!xsIsInstanceOf(xsResult, mod->z->z_protoInteger) || (mod->m = xsGetHostData(xsResult)) == NULL)
nanError();
bn_mod_init(mod->mod_data, mod->z->z_data, mod->m->cint_data, options);
xsSetHostData(xsThis, mod);
}
示例2: KPR_mqttclient_subscribe
void KPR_mqttclient_subscribe(xsMachine* the)
{
KPR_MQTTClientRecord *self = xsGetHostData(xsThis);
FskErr err = kFskErrNone;
xsIntegerValue c = xsToInteger(xsArgc);
char **topics = NULL;
UInt8 *qoss = NULL;
int i, count;
UInt16 token;
if (c == 0 || (c % 2) != 0) xsThrowIfFskErr(kFskErrParameterError);
count = c / 2;
bailIfError(FskMemPtrNew(sizeof(char*) * count, &topics));
bailIfError(FskMemPtrNew(sizeof(UInt8*) * count, &qoss));
for (i = 0; i < count; i++) {
topics[i] = xsToString(xsArg(i * 2));
qoss[i] = xsToInteger(xsArg(i * 2 + 1));
}
bailIfError(KprMQTTClientSubscribeTopics(self->client, topics, qoss, count, &token));
xsResult = xsInteger(token);
bail:
FskMemPtrDispose(topics);
FskMemPtrDispose(qoss);
xsThrowIfFskErr(err);
}
示例3: KprURLMerge
FskErr KprURLMerge(char* base, char* reference, char** result)
{
FskErr err = kFskErrNone;
KprURLPartsRecord parts;
KprURLPartsRecord baseParts;
char* path = NULL;
UInt32 length;
KprURLSplit(reference, &parts);
if (!parts.scheme) {
KprURLSplit(base, &baseParts);
parts.scheme = baseParts.scheme;
parts.schemeLength = baseParts.schemeLength;
if (!parts.authority) {
parts.authority = baseParts.authority;
parts.authorityLength = baseParts.authorityLength;
if (!parts.pathLength) {
if (baseParts.authority && !baseParts.pathLength) {
bailIfError(FskMemPtrNew(1, &path));
FskMemMove(path, "/", 1);
parts.path = path;
parts.pathLength = 1;
}
else {
parts.path = baseParts.path;
parts.pathLength = baseParts.pathLength;
}
if (!parts.query) {
parts.query = baseParts.query;
parts.queryLength = baseParts.queryLength;
}
}
else if (*parts.path != '/') {
if (baseParts.authority && !baseParts.pathLength) {
bailIfError(FskMemPtrNew(1 + parts.pathLength, &path));
FskMemMove(path, "/", 1);
FskMemMove(path + 1, parts.path, parts.pathLength);
parts.path = path;
parts.pathLength++;
}
else if (baseParts.name) {
length = baseParts.name - baseParts.path;
bailIfError(FskMemPtrNew(length + parts.pathLength, &path));
FskMemMove(path, baseParts.path, length);
FskMemMove(path + length, parts.path, parts.pathLength);
parts.path = path;
parts.pathLength += length;
}
}
}
}
bailIfError(KprURLJoin(&parts, result));
bail:
FskMemPtrDispose(path);
return err;
}
示例4: httpServerListenerStart
static FskErr httpServerListenerStart(FskHTTPServerListener listener, FskSocket skt) {
FskErr err = kFskErrNone;
FskHTTPServerRequest request;
if (listener->http->stopped) {
FskInstrumentedItemSendMessage(listener->http, kFskHTTPInstrMsgConnectionRefusedStopped, listener);
listener->http->stats.connectionsRefused++;
FskNetSocketClose(skt);
goto bail;
}
err = FskMemPtrNewClear(sizeof(FskHTTPServerRequestRecord), (FskMemPtr*)&request);
BAIL_IF_ERR(err);
sFskHTTPServerRequestUpUse(request);
request->http = listener->http;
request->skt = skt;
FskNetSocketGetRemoteAddress(skt, (UInt32 *)&request->requesterAddress, &request->requesterPort);
FskNetSocketMakeNonblocking(request->skt);
err = FskHeaderStructNew(&request->requestHeaders);
BAIL_IF_ERR(err);
err = FskHeaderStructNew(&request->responseHeaders);
BAIL_IF_ERR(err);
request->in.bufferSize = request->http->defaultBufferSize;
request->out.bufferSize = request->http->defaultBufferSize;
err = FskMemPtrNew(request->in.bufferSize, (FskMemPtr*)&request->in.buf);
BAIL_IF_ERR(err);
err = FskMemPtrNew(request->out.bufferSize, (FskMemPtr*)&request->out.buf);
BAIL_IF_ERR(err);
FskListAppend((FskList*)&request->http->activeRequests, request);
FskTimeCallbackNew(&request->cycleCallback);
FskTimeCallbackNew(&request->keepAliveKillCallback);
listener->http->stats.connectionsMade++;
request->state = kHTTPNewSession;
FskInstrumentedItemNew(request, NULL, &gFskHTTPServerRequestTypeInstrumentation);
FskInstrumentedItemSetOwner(request, request->http);
FskTimeCallbackScheduleNextRun(request->cycleCallback, httpServerTimeCycle, request);
doCallCondition(request->http->callbacks->requestCondition, request, kFskHTTPConditionConnectionInitialized, request->refCon);
FskTimeCallbackNew(&request->timer);
FskTimeCallbackScheduleFuture(request->timer, 1, 0, KprHTTPServerTimerCallback, request);
bail:
if (err)
FskHTTPServerRequestDispose(request);
return err;
}
示例5: sFskNetInterfaceEnumerate
static FskErr sFskNetInterfaceEnumerate(FskNetInterfaceRecord **interfaceList)
{
FskErr err;
KplNetInterfaceRecord *kplInterfaceList;
*interfaceList = NULL;
err = KplNetInterfaceEnumerate(&kplInterfaceList);
BAIL_IF_ERR(err);
while (kplInterfaceList) {
FskNetInterfaceRecord *nir;
KplNetInterfaceRecord *next = kplInterfaceList->next;
err = FskMemPtrNew(sizeof(FskNetInterfaceRecord), (FskMemPtr*)&nir);
BAIL_IF_ERR(err);
nir->name = FskStrDoCopy(kplInterfaceList->name);
nir->ip = kplInterfaceList->ip;
FskMemMove(nir->MAC, kplInterfaceList->MAC, sizeof(nir->MAC));
nir->status = kplInterfaceList->status;
nir->netmask = kplInterfaceList->netmask;
FskListAppend((FskList*)interfaceList, nir);
FskMemPtrDispose(kplInterfaceList->name);
FskMemPtrDispose(kplInterfaceList);
kplInterfaceList = next;
}
bail:
return err;
}
示例6: KprWebSocketEndpointStartClosingHandshake
static FskErr KprWebSocketEndpointStartClosingHandshake(KprWebSocketEndpoint self, UInt16 code, char *reason)
{
FskErr err = kFskErrNone;
char *payload = NULL;
UInt32 length = sizeof(UInt16);
self->state = kKprWebSocketStateClosing;
CALLBACK(closingCallback)(self, self->closeCode, self->closeReason, self->cleanClose, self->refcon);
length += FskStrLen(reason);
bailIfError(FskMemPtrNew(length, &payload));
*((UInt16 *) payload) = FskEndianU16_NtoB(code);
FskMemCopy(&payload[2], reason, length - sizeof(UInt16));
bailIfError(KprWebSocketEndpointSendRawFrame(self, kKprWebSocketOpcodeClose, payload, length));
self->closeWasSent = true;
bail:
if (payload) FskMemPtrDispose(payload);
if (err || (self->closeWasSent && self->closeWasReceived)) {
self->cleanClose = (err == kFskErrNone);
KprWebSocketEndpointDisconnect(self);
}
return err;
}
示例7: KprNetworkInterfaceCallback
VOID __stdcall KprNetworkInterfaceCallback(PVOID context, PMIB_IPINTERFACE_ROW interfaceRow, MIB_NOTIFICATION_TYPE notificationType)
{
int ip;
FskErr err = kFskErrNone;
IP_ADAPTER_INFO *adapters = NULL;
DWORD result;
DWORD size = 15000;
IP_ADAPTER_INFO *adapter;
IP_ADDR_STRING *address;
for (ip = 0; ip < 3; ip++) {
err = FskMemPtrNew(size, &adapters);
result = GetAdaptersInfo(adapters, &size);
if (ERROR_BUFFER_OVERFLOW == result) {
FskMemPtrDispose(adapters);
adapters = NULL;
}
else
break;
}
if (ERROR_SUCCESS == result) {
for (adapter = adapters ; NULL != adapter ; adapter = adapter->Next) {
for (address = &adapter->IpAddressList; address; address = address->Next) {
if (FskStrLen(address->IpAddress.String) == 0)
continue;
FskNetStringToIPandPort(address->IpAddress.String, &ip, NULL);
if (0x7f000001 != ip)
KprNetworkInterfaceMark(ip, adapter->AdapterName);
}
}
KprNetworkInterfaceSweep();
}
FskMemPtrDispose(adapters);
}
示例8: KprWebSocketServerRequestNew
static FskErr KprWebSocketServerRequestNew(KprWebSocketServerRequest *it, KprWebSocketServer server, FskSocket skt) {
FskErr err = kFskErrNone;
KprWebSocketServerRequest request = NULL;
bailIfError(FskMemPtrNewClear(sizeof(KprWebSocketServerRequestRecord), &request));
request->server = server;
request->skt = skt;
skt = NULL;
FskNetSocketGetRemoteAddress(request->skt, (UInt32 *)&request->requesterAddress, &request->requesterPort);
FskNetSocketMakeNonblocking(request->skt);
bailIfError(FskHeaderStructNew(&request->requestHeaders));
bailIfError(FskHeaderStructNew(&request->responseHeaders));
request->out.size = 512;
bailIfError(FskMemPtrNew(request->out.size, &request->out.buffer));
FskThreadAddDataHandler(&request->dataHandler, (FskThreadDataSource)request->skt, (FskThreadDataReadyCallback)KprWebSocketServerRequestDoRead, true, false, request);
// request->state = kHTTPNewSession;
*it = request;
bail:
if (err) {
KprWebSocketServerRequestDispose(request);
FskNetSocketClose(skt);
}
return err;
}
示例9: KprQuerySerialize
FskErr KprQuerySerialize(FskAssociativeArray array, char** it)
{
FskErr err = kFskErrNone;
FskAssociativeArrayIterator iterate = FskAssociativeArrayIteratorNew(array);
SInt32 length = 0;
char* p;
while (iterate) {
if (length)
length++;
length += FskStrLen(iterate->name);
length++;
length += FskStrLen(iterate->value);
}
length++;
FskAssociativeArrayIteratorDispose(iterate);
iterate = NULL;
bailIfError(FskMemPtrNew(length, it));
iterate = FskAssociativeArrayIteratorNew(array);
p = *it;
*p = 0;
while (iterate) {
if (*p)
*p++ = '&';
FskStrCopy(p, iterate->name);
p += FskStrLen(iterate->name);
*p++ = '=';
FskStrCopy(p, iterate->value);
p += FskStrLen(iterate->value);
}
*p = 0;
FskAssociativeArrayIteratorDispose(iterate);
bail:
return err;
}
示例10: KprAuthorityReverse
FskErr KprAuthorityReverse(char* id, char** di)
{
FskErr err = kFskErrNone;
char *p, *q;
SInt32 c = FskStrLen(id), i;
bailIfError(FskMemPtrNew(c + 1, di));
p = id + c;
q = *di;
i = 0;
while (c) {
c--;
p--;
if (*p == '.') {
p++;
FskMemCopy(q, p, i);
q += i;
*q++ = '.';
p--;
i = 0;
}
else
i++;
}
FskMemCopy(q, p, i);
q += i;
*q = 0;
bail:
return err;
}
示例11: FskAssociativeArrayElementSet
// ------------------------------------------------------------------------
void FskAssociativeArrayElementSet(FskAssociativeArray array, const char *name, const void *value, UInt32 valueSize, SInt32 valueType)
{
FskAssociativeArrayNameList list;
SInt32 nameLen = FskStrLen(name) + 1;
if (kFskStringType == valueType)
valueSize = FskStrLen((const char *)value) + 1;
else if (kFskBlobType == valueType)
;
else
valueSize = 0;
FskAssociativeArrayElementDispose(array, name);
if (kFskErrNone == FskMemPtrNew(sizeof(FskAssociativeArrayNameListRec) + nameLen + valueSize, &list)) {
unsigned char *d = list->data;
list->name = (char *)d;
FskMemMove(d, name, nameLen);
d += nameLen;
list->valueType = valueType;
list->valueSize = valueSize;
list->next = NULL;
if ((kFskStringType == valueType) || (kFskBlobType == valueType)) {
FskMemMove(d, value, valueSize);
list->value = (char *)d;
}
else
list->value = (char *)value;
FskListPrepend((FskList*)(void*)&array->arrayHead, (FskListElement)list);
}
}
示例12: KplFileGetPathInfo
FskErr KplFileGetPathInfo(const char *rootpath, const char *filepath, KplFileInfo *itemInfo) {
int err;
STATTYPE statbuf;
char *fullpath;
err = FskMemPtrNew(FskStrLen(rootpath) + FskStrLen(filepath) + 2, (FskMemPtr *)&fullpath);
if (err) return err;
FskStrCopy(fullpath, rootpath);
FskStrCat(fullpath, "/");
FskStrCat(fullpath, filepath);
err = STAT(fullpath, &statbuf);
if (err == -1) {
err = errnoToFskErr(errno);
goto bail;
}
GetFileInfoFromStat(&statbuf, itemInfo);
bail:
FskMemPtrDispose(fullpath);
return err;
}
示例13: KprWebSocketEndpointReadFrameMessage
static FskErr KprWebSocketEndpointReadFrameMessage(KprSocketReader reader, KprWebSocketEndpoint self)
{
FskErr err = kFskErrNone;
UInt32 length = self->read.length;
if (length > 0) {
if (self->read.message == NULL) {
err = FskMemPtrNew(length, &self->read.message);
if (err != kFskErrNone) return err;
}
err = KprSocketReaderReadBytes(reader, self->read.message, length);
if (err != kFskErrNone) return err;
if (self->read.mask) {
KprWebSocketMask((UInt8 *) self->read.message, length, self->read.maskData);
}
}
KprSocketReaderSetState(reader, kKprWebSocketEndpoint_onFrameOpcode);
if ((self->needMaskedFrame && !self->read.mask)
|| (self->needNonMaskedFrame && self->read.mask)) {
self->ignoreFurtherFrame = true;
bailIfError(kFskErrBadData);
}
err = KprWebSocketEndpointHandleFrame(self, self->read.opcode, self->read.message, length);
bail:
FskMemPtrDisposeAt(&self->read.message);
return err;
}
示例14: FillJaggyPolygonContours
static FskErr
FillJaggyPolygonContours(
UInt32 nContours,
const UInt32 *nPts,
const FskFixedPoint2D *pts,
const FskColorSource *colorSource,
SInt32 fillRule,
const FskFixedMatrix3x2 *M,
FskConstRectangle clipRect,
FskBitmap dstBM
)
{
FskRectangleRecord dstRect;
LinkedEdge edges[MAX_EDGES], *pEdges = edges; /* Small polygons use auto edges, large ones need to be alloc'ed */
UInt32 numEdges, totPts;
FskSpan span;
FskErr err = kFskErrNone;
SInt32 n;
const UInt32 *np;
LinkedEdge *pe;
static FskInitSpanProc initProcs[] = {
FskInitSolidColorSpan,
FskInitLinearGradientSpan,
FskInitRadialGradientSpan,
FskInitTextureSpan,
NULL /* Procedure span is not yet implemented */
};
FskInitSpanProc initSpan;
if (clipRect == NULL) dstRect = dstBM->bounds;
else if (!FskRectangleIntersect(&dstBM->bounds, clipRect, &dstRect)) return kFskErrNothingRendered;
for (n = nContours, np = nPts, totPts = 0; n--; )
totPts += *np++;
FskInitSpan(&span, dstBM, sizeof(LinkedEdge)); /* Generic span init */
initSpan = initProcs[((n = colorSource->type) <= kFskColorSourceTypeMax) ? n : 0];
if ((err = (*initSpan)(&span, dstBM, M, 0, colorSource)) != kFskErrNone) /* Specialized span init - this may bump up the edge size */
return err;
span.edgeBytes = (span.edgeBytes + 3) & ~3; /* Ceil up to multiple of 4 bytes */
if ( CANT_USE_AUTO_EDGES(totPts) /* Either small enough for auto storage ... */
&& (err = (FskMemPtrNew(totPts * CLIP_MULTIPLIER * sizeof(LinkedEdge), (FskMemPtr*)(void*)(&pEdges))) != kFskErrNone) /* ... or we can allocate memory */
)
return err; /* Polygon is too big to render */
for (numEdges = 0, pe = pEdges; nContours--; pts += *nPts++, numEdges += n, pe += n)
BAIL_IF_NEGATIVE(n = TransformClipAndMakeEdges(*nPts, pts, M, &dstRect, &span, pe), err, kFskErrMemFull);
BAIL_IF_FALSE(numEdges >= 2, err, kFskErrNothingRendered);
err = ScanConvertLinkedEdges(numEdges, pEdges, fillRule, &span);
bail:
if (pEdges != edges)
FskMemPtrDispose(pEdges); /* Deallocate big polygon edges */
if ((span.disposeSpanData != NULL) && (span.spanData != NULL))
span.disposeSpanData(span.spanData);
return err;
}
示例15: loadGrammar
FskErr loadGrammar(const char *xsbPath, xsGrammar *theGrammar)
{
FskErr err;
FskFile fref = NULL;
UInt32 atom[2];
err = FskFileOpen(xsbPath, kFskFilePermissionReadOnly, &fref);
if (err) goto bail;
err = FskFileRead(fref, sizeof(atom), atom, NULL);
if (err) goto bail;
atom[0] = FskEndianU32_BtoN(atom[0]);
atom[1] = FskEndianU32_BtoN(atom[1]);
if (atom[1] == 'XS11') {
SInt32 totalSize = (SInt32)atom[0] - sizeof(atom);
while (totalSize > 0) {
UInt32 blockSize;
char *block;
err = FskFileRead(fref, sizeof(atom), atom, NULL);
if (err) break;
atom[0] = FskEndianU32_BtoN(atom[0]);
atom[1] = FskEndianU32_BtoN(atom[1]);
totalSize -= atom[0];
blockSize = atom[0] - sizeof(atom);
err = FskMemPtrNew(blockSize, &block);
if (err) break;
err = FskFileRead(fref, blockSize, block, NULL);
if (err) break;
switch (atom[1]) {
case 'SYMB':
theGrammar->symbols = block;
theGrammar->symbolsSize = blockSize;
break;
case 'CODE':
theGrammar->code = block;
theGrammar->codeSize = blockSize;
break;
default:
FskMemPtrDispose(block);
err = kFskErrBadData;
break;
}
}
}
else
err = kFskErrBadData;
bail:
FskFileClose(fref);
return err;
}