Esempio n. 1
0
static void *operator_new(pj_pool_factory *factory, pj_size_t size)
{
    void *mem;

    PJ_CHECK_STACK();

    if (factory->on_block_alloc) {
		int rc;
		rc = factory->on_block_alloc(factory, size);
		if (!rc)
		    return NULL;
    }
    
    mem = (void*) new char[size+(SIG_SIZE << 1)];
    
    /* Exception for new operator may be disabled, so.. */
    if (mem) {
	/* Apply signature when PJ_SAFE_POOL is set. It will move
	 * "mem" pointer forward.
	 */
	APPLY_SIG(mem, size);
    }

    return mem;
}
Esempio n. 2
0
static void *default_block_alloc(pj_pool_factory *factory, pj_size_t size)
{
    void *p;

    PJ_CHECK_STACK();

    if (factory->on_block_alloc) {
	int rc;
	rc = factory->on_block_alloc(factory, size);
	if (!rc)
	    return NULL;
    }

    p = malloc(size+(SIG_SIZE << 1));

    if (p == NULL) {
	if (factory->on_block_free) 
	    factory->on_block_free(factory, size);
    } else {
	/* Apply signature when PJ_SAFE_POOL is set. It will move
	 * "p" pointer forward.
	 */
	APPLY_SIG(p, size);
    }

    return p;
}