本文整理汇总了C++中CMEM2Alloc::allocate方法的典型用法代码示例。如果您正苦于以下问题:C++ CMEM2Alloc::allocate方法的具体用法?C++ CMEM2Alloc::allocate怎么用?C++ CMEM2Alloc::allocate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMEM2Alloc
的用法示例。
在下文中一共展示了CMEM2Alloc::allocate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void *MEM1_alloc(unsigned int s)
{
if(g_mem1Lgp.FreeSize() >= s)
return g_mem1Lgp.allocate(s);
if(g_mem1Ugp.FreeSize() >= s)
return g_mem1Ugp.allocate(s);
return NULL;
}
示例2: __real_malloc
void *__wrap_malloc(size_t size)
{
void *p;
if(size >= MEM2_PRIORITY_SIZE)
{
p = g_mem2gp.allocate(size);
if(p != 0)
return p;
return __real_malloc(size);
}
p = __real_malloc(size);
if(p != 0)
return p;
return g_mem2gp.allocate(size);
}
示例3:
void *__wrap_realloc(void *p, size_t size)
{
void *n;
// ptr from mem2
if(((u32)p & 0x10000000) != 0 || (p == 0 && size > MEM2_PRIORITY_SIZE))
{
n = g_mem2gp.reallocate(p, size);
if(n != 0)
return n;
n = __real_malloc(size);
if(n == 0)
return 0;
if(p != 0)
{
memcpy(n, p, MEM2_usableSize(p) < size ? MEM2_usableSize(p) : size);
g_mem2gp.release(p);
}
return n;
}
// ptr from malloc
n = __real_realloc(p, size);
if(n != 0)
return n;
n = g_mem2gp.allocate(size);
if(n == 0)
return 0;
if(p != 0)
{
memcpy(n, p, __real_malloc_usable_size(p) < size ? __real_malloc_usable_size(p) : size);
__real_free(p);
}
return n;
}
示例4: __real_malloc
void *__wrap_malloc(size_t size)
{
void *p;
if ((SYS_GetArena1Lo() > MAX_MEM1_ARENA_LO) || (g_bigGoesToMem2 && size > MEM2_PRIORITY_SIZE))
{
p = g_mem2gp.allocate(size);
if (p != 0) {
return p;
}
return __real_malloc(size);
}
p = __real_malloc(size);
if (p != 0) {
return p;
}
return g_mem2gp.allocate(size);
}
示例5: __real_memalign
void *__wrap_memalign(size_t a, size_t size)
{
void *p;
if(size >= MEM2_PRIORITY_SIZE)
{
if(a <= 32 && 32 % a == 0)
{
p = g_mem2gp.allocate(size);
if (p != 0)
return p;
}
return __real_memalign(a, size);
}
p = __real_memalign(a, size);
if(p != 0 || a > 32 || 32 % a != 0)
return p;
return g_mem2gp.allocate(size);
}
示例6: __real_memalign
void *__wrap_memalign(size_t a, size_t size)
{
void *p;
if ((SYS_GetArena1Lo() > MAX_MEM1_ARENA_LO) || (g_bigGoesToMem2 && size > MEM2_PRIORITY_SIZE))
{
if (a <= 32 && 32 % a == 0)
{
p = g_mem2gp.allocate(size);
if (p != 0) {
return p;
}
}
return __real_memalign(a, size);
}
p = __real_memalign(a, size);
if (p != 0 || a > 32 || 32 % a != 0) {
return p;
}
return g_mem2gp.allocate(size);
}
示例7: __real_calloc
void *__wrap_calloc(size_t n, size_t size)
{
void *p;
if((n * size) >= MEM2_PRIORITY_SIZE)
{
p = g_mem2gp.allocate(n * size);
if (p != 0)
{
memset(p, 0, n * size);
return p;
}
return __real_calloc(n, size);
}
p = __real_calloc(n, size);
if (p != 0) return p;
p = g_mem2gp.allocate(n * size);
if (p != 0)
memset(p, 0, n * size);
return p;
}