本文整理汇总了C++中cpcalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ cpcalloc函数的具体用法?C++ cpcalloc怎么用?C++ cpcalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cpcalloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: handlerSetTrans
// Transformation function for collisionHandlers.
static void *
handlerSetTrans(cpCollisionHandler *handler, void *unused)
{
cpCollisionHandler *copy = (cpCollisionHandler *)cpcalloc(1, sizeof(cpCollisionHandler));
memcpy(copy, handler, sizeof(cpCollisionHandler));
return copy;
}
开发者ID:abakobo,项目名称:monkey2,代码行数:9,代码来源:cpSpace.c
示例2: cpSpaceHashAllocTable
// Frees the old table, and allocates a new one.
static void
cpSpaceHashAllocTable(cpSpaceHash *hash, int numcells)
{
cpfree(hash->table);
hash->numcells = numcells;
hash->table = (cpSpaceHashBin **)cpcalloc(numcells, sizeof(cpSpaceHashBin *));
}
开发者ID:bcolombini,项目名称:Learn-iPhone-and-iPad-cocos2d-Game-Development,代码行数:9,代码来源:cpSpaceHash.c
示例3: postStepFuncSetTrans
static void *
postStepFuncSetTrans(cpPostStepCallback *callback, void *ignored)
{
cpPostStepCallback *value = (cpPostStepCallback *)cpcalloc(1, sizeof(cpPostStepCallback));
(*value) = (*callback);
return value;
}
开发者ID:AntonioModer,项目名称:Cheetah,代码行数:8,代码来源:cpSpaceStep.c
示例4: collFuncSetTrans
// Transformation function for collFuncSet.
static void *
collFuncSetTrans(cpCollisionHandler *handler, void *unused)
{
cpCollisionHandler *copy = (cpCollisionHandler *)cpcalloc(1, sizeof(cpCollisionHandler));
(*copy) = (*handler);
return copy;
}
开发者ID:ccjimmy,项目名称:TweeJump4wp8,代码行数:9,代码来源:cpSpace.c
示例5: cpHashSetNew
cpHashSet *
cpHashSetNew(int size, cpHashSetEqlFunc eqlFunc)
{
cpHashSet *set = (cpHashSet *)cpcalloc(1, sizeof(cpHashSet));
set->size = next_prime(size);
set->entries = 0;
set->eql = eqlFunc;
set->default_value = NULL;
set->table = (cpHashSetBin **)cpcalloc(set->size, sizeof(cpHashSetBin *));
set->pooledBins = NULL;
set->allocatedBuffers = cpArrayNew(0);
return set;
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:18,代码来源:cpHashSet.c
示例6: cpPolylineSetInit
cpPolylineSet *
cpPolylineSetInit(cpPolylineSet *set)
{
set->count = 0;
set->capacity = 8;
set->lines = cpcalloc(set->capacity, sizeof(cpPolyline));
return set;
}
开发者ID:cxuhua,项目名称:cxengine,代码行数:9,代码来源:cpPolyline.c
示例7: cpPolylineMake
static cpPolyline *
cpPolylineMake(int capacity)
{
capacity = (capacity > DEFAULT_POLYLINE_CAPACITY ? capacity : DEFAULT_POLYLINE_CAPACITY);
cpPolyline *line = (cpPolyline *)cpcalloc(1, cpPolylineSizeForCapacity(capacity));
line->count = 0;
line->capacity = capacity;
return line;
}
开发者ID:cxuhua,项目名称:cxengine,代码行数:11,代码来源:cpPolyline.c
示例8: setUpVerts
static void
setUpVerts(cpPolyShape *poly, int numVerts, cpVect *verts, cpVect offset)
{
poly->numVerts = numVerts;
poly->verts = (cpVect *)cpcalloc(numVerts, sizeof(cpVect));
poly->tVerts = (cpVect *)cpcalloc(numVerts, sizeof(cpVect));
poly->axes = (cpPolyShapeAxis *)cpcalloc(numVerts, sizeof(cpPolyShapeAxis));
poly->tAxes = (cpPolyShapeAxis *)cpcalloc(numVerts, sizeof(cpPolyShapeAxis));
for(int i=0; i<numVerts; i++){
cpVect a = cpvadd(offset, verts[i]);
cpVect b = cpvadd(offset, verts[(i+1)%numVerts]);
cpVect n = cpvnormalize(cpvperp(cpvsub(b, a)));
poly->verts[i] = a;
poly->axes[i].n = n;
poly->axes[i].d = cpvdot(n, a);
}
}
开发者ID:Avant-Flux,项目名称:chipmunk,代码行数:20,代码来源:cpPolyShape.c
示例9: cpInitCollisionFuncs
// Initializes the array of collision functions.
// Called by cpInitChipmunk().
void
cpInitCollisionFuncs(void)
{
if(!colfuncs)
colfuncs = (collisionFunc *)cpcalloc(CP_NUM_SHAPES*CP_NUM_SHAPES, sizeof(collisionFunc));
addColFunc(CP_CIRCLE_SHAPE, CP_CIRCLE_SHAPE, circle2circle);
addColFunc(CP_CIRCLE_SHAPE, CP_SEGMENT_SHAPE, circle2segment);
addColFunc(CP_SEGMENT_SHAPE, CP_POLY_SHAPE, seg2poly);
addColFunc(CP_CIRCLE_SHAPE, CP_POLY_SHAPE, circle2poly);
addColFunc(CP_POLY_SHAPE, CP_POLY_SHAPE, poly2poly);
}
开发者ID:BellyWong,项目名称:RubyCocos2D,代码行数:14,代码来源:cpCollision.c
示例10: setUpVerts
static void
setUpVerts(cpPolyShape *poly, int numVerts, const cpVect *verts, cpVect offset)
{
// Fail if the user attempts to pass a concave poly, or a bad winding.
cpAssertHard(cpPolyValidate(verts, numVerts), "Polygon is concave or has a reversed winding. Consider using cpConvexHull() or CP_CONVEX_HULL().");
poly->numVerts = numVerts;
poly->verts = (cpVect *)cpcalloc(2*numVerts, sizeof(cpVect));
poly->planes = (cpSplittingPlane *)cpcalloc(2*numVerts, sizeof(cpSplittingPlane));
poly->tVerts = poly->verts + numVerts;
poly->tPlanes = poly->planes + numVerts;
for(int i=0; i<numVerts; i++) {
cpVect a = cpvadd(offset, verts[i]);
cpVect b = cpvadd(offset, verts[(i+1)%numVerts]);
cpVect n = cpvnormalize(cpvperp(cpvsub(b, a)));
poly->verts[i] = a;
poly->planes[i].n = n;
poly->planes[i].d = cpvdot(n, a);
}
}
开发者ID:pes6pro,项目名称:visva,代码行数:23,代码来源:cpPolyShape.c
示例11: cpHashSetInit
cpHashSet *
cpHashSetInit(cpHashSet *set, int size, cpHashSetEqlFunc eqlFunc, cpHashSetTransFunc trans)
{
set->size = next_prime(size);
set->entries = 0;
set->eql = eqlFunc;
set->trans = trans;
set->default_value = NULL;
set->table = (cpHashSetBin **)cpcalloc(set->size, sizeof(cpHashSetBin *));
return set;
}
开发者ID:JINXSHADYLANE,项目名称:quibble,代码行数:15,代码来源:cpHashSet.c
示例12: cpSpaceArbiterSetTrans
static void *
cpSpaceArbiterSetTrans(cpShape **shapes, cpSpace *space)
{
if(space->pooledArbiters->num == 0){
// arbiter pool is exhausted, make more
int count = CP_BUFFER_BYTES/sizeof(cpArbiter);
cpAssertSoft(count, "Buffer size too small.");
cpArbiter *buffer = (cpArbiter *)cpcalloc(1, CP_BUFFER_BYTES);
cpArrayPush(space->allocatedBuffers, buffer);
for(int i=0; i<count; i++) cpArrayPush(space->pooledArbiters, buffer + i);
}
return cpArbiterInit((cpArbiter *)cpArrayPop(space->pooledArbiters), shapes[0], shapes[1]);
}
开发者ID:50Cubes,项目名称:ClusterFear,代码行数:16,代码来源:cpSpaceStep.c
示例13: cpSpaceAddPostStepCallback
cpBool
cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data)
{
cpAssertWarn(space->locked,
"Adding a post-step callback when the space is not locked is unnecessary. "
"Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query.");
if(!cpSpaceGetPostStepCallback(space, key)){
cpPostStepCallback *callback = (cpPostStepCallback *)cpcalloc(1, sizeof(cpPostStepCallback));
callback->func = (func ? func : PostStepDoNothing);
callback->key = key;
callback->data = data;
cpArrayPush(space->postStepCallbacks, callback);
return cpTrue;
} else {
return cpFalse;
}
}
开发者ID:cxuhua,项目名称:cxengine,代码行数:19,代码来源:cpSpaceStep.c
示例14: SetVerts
static void
SetVerts(cpPolyShape *poly, int count, const cpVect *verts)
{
poly->count = count;
if(count <= CP_POLY_SHAPE_INLINE_ALLOC){
poly->planes = poly->_planes;
} else {
poly->planes = (struct cpSplittingPlane *)cpcalloc(2*count, sizeof(struct cpSplittingPlane));
}
for(int i=0; i<count; i++){
cpVect a = verts[(i - 1 + count)%count];
cpVect b = verts[i];
cpVect n = cpvnormalize(cpvrperp(cpvsub(b, a)));
poly->planes[i + count].v0 = b;
poly->planes[i + count].n = n;
}
}
开发者ID:ConfusedReality,项目名称:pkg_game-engine_chipmunk,代码行数:19,代码来源:cpPolyShape.cpp
示例15: handleSetTrans
static void *
handleSetTrans(void *obj, cpSpaceHash *hash)
{
if(hash->pooledHandles->num == 0){
// handle pool is exhausted, make more
int count = CP_BUFFER_BYTES/sizeof(cpHandle);
cpAssertSoft(count, "Buffer size is too small.");
cpHandle *buffer = (cpHandle *)cpcalloc(1, CP_BUFFER_BYTES);
cpArrayPush(hash->allocatedBuffers, buffer);
for(int i=0; i<count; i++) cpArrayPush(hash->pooledHandles, buffer + i);
}
cpHandle *hand = cpHandleInit((cpHandle *)cpArrayPop(hash->pooledHandles), obj);
cpHandleRetain(hand);
return hand;
}
开发者ID:EduardoFF,项目名称:argos2-RoboNetSim,代码行数:19,代码来源:cpSpaceHash.c
示例16: cpHastySpaceNew
cpSpace *
cpHastySpaceNew(void)
{
cpHastySpace *hasty = (cpHastySpace *)cpcalloc(1, sizeof(cpHastySpace));
cpSpaceInit((cpSpace *)hasty);
pthread_mutex_init(&hasty->mutex, NULL);
pthread_cond_init(&hasty->cond_work, NULL);
pthread_cond_init(&hasty->cond_resume, NULL);
// TODO magic number, should test this more thoroughly.
hasty->constraint_count_threshold = 50;
// Default to 1 thread for determinism.
hasty->num_threads = 1;
cpHastySpaceSetThreads((cpSpace *)hasty, 1);
return (cpSpace *)hasty;
}
开发者ID:cxuhua,项目名称:cxengine,代码行数:19,代码来源:cpHastySpace.c
示例17: NodeFromPool
static Node *
NodeFromPool(cpBBTree *tree)
{
Node *node = tree->pooledNodes;
if(node){
tree->pooledNodes = node->parent;
return node;
} else {
// Pool is exhausted, make more
int count = CP_BUFFER_BYTES/sizeof(Node);
cpAssertHard(count, "Internal Error: Buffer size is too small.");
Node *buffer = (Node *)cpcalloc(1, CP_BUFFER_BYTES);
cpArrayPush(tree->allocatedBuffers, buffer);
// push all but the first one, return the first instead
for(int i=1; i<count; i++) NodeRecycle(tree, buffer + i);
return buffer;
}
}
开发者ID:0xiaohui00,项目名称:Cocos2dx-Wechat,代码行数:21,代码来源:cpBBTree.c
示例18: getUnusedBin
static cpHashSetBin *
getUnusedBin(cpHashSet *set)
{
cpHashSetBin *bin = set->pooledBins;
if(bin){
set->pooledBins = bin->next;
return bin;
} else {
// Pool is exhausted, make more
int count = CP_BUFFER_BYTES/sizeof(cpHashSetBin);
cpAssertHard(count, "Internal Error: Buffer size is too small.");
cpHashSetBin *buffer = (cpHashSetBin *)cpcalloc(1, CP_BUFFER_BYTES);
cpArrayPush(set->allocatedBuffers, buffer);
// push all but the first one, return it instead
for(int i=1; i<count; i++) recycleBin(set, buffer + i);
return buffer;
}
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:21,代码来源:cpHashSet.c
示例19: getEmptyBin
// Get a recycled or new bin.
static inline cpSpaceHashBin *
getEmptyBin(cpSpaceHash *hash)
{
cpSpaceHashBin *bin = hash->pooledBins;
if(bin){
hash->pooledBins = bin->next;
return bin;
} else {
// Pool is exhausted, make more
int count = CP_BUFFER_BYTES/sizeof(cpSpaceHashBin);
cpAssertSoft(count, "Buffer size is too small.");
cpSpaceHashBin *buffer = (cpSpaceHashBin *)cpcalloc(1, CP_BUFFER_BYTES);
cpArrayPush(hash->allocatedBuffers, buffer);
// push all but the first one, return the first instead
for(int i=1; i<count; i++) recycleBin(hash, buffer + i);
return buffer;
}
}
开发者ID:EduardoFF,项目名称:argos2-RoboNetSim,代码行数:22,代码来源:cpSpaceHash.c
示例20: PairFromPool
static Pair *
PairFromPool(cpBBTree *tree)
{
Pair *pair = tree->pooledPairs;
if(pair){
tree->pooledPairs = pair->a.next;
return pair;
} else {
// Pool is exhausted, make more
int count = CP_BUFFER_BYTES/sizeof(Pair);
cpAssertHard(count, "Internal Error: Buffer size is too small.");
Pair *buffer = (Pair *)cpcalloc(1, CP_BUFFER_BYTES);
cpArrayPush(tree->allocatedBuffers, buffer);
// push all but the first one, return the first instead
for(int i=1; i<count; i++) PairRecycle(tree, buffer + i);
return buffer;
}
}
开发者ID:haiweizhang,项目名称:MyCocos2d-xV2.0,代码行数:21,代码来源:cpBBTree.c
注:本文中的cpcalloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论