~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-common/libs/pjproject/pjlib/src/pj/pool_policy_new.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* $Id: pool_policy_new.cpp 2394 2008-12-23 17:27:53Z bennylp $ */
2
 
/* 
 
2
/*
3
3
 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
4
4
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5
5
 *
15
15
 *
16
16
 * You should have received a copy of the GNU General Public License
17
17
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
19
 *
20
20
 *  Additional permission under GNU GPL version 3 section 7:
21
21
 *
38
38
 * This file contains pool default policy definition and implementation.
39
39
 */
40
40
#include "pool_signature.h"
41
 
 
42
 
 
43
 
static void *operator_new(pj_pool_factory *factory, pj_size_t size)
 
41
 
 
42
 
 
43
static void *operator_new (pj_pool_factory *factory, pj_size_t size)
44
44
{
45
45
    void *mem;
46
46
 
47
47
    PJ_CHECK_STACK();
48
48
 
49
49
    if (factory->on_block_alloc) {
50
 
                int rc;
51
 
                rc = factory->on_block_alloc(factory, size);
52
 
                if (!rc)
53
 
                    return NULL;
 
50
        int rc;
 
51
        rc = factory->on_block_alloc (factory, size);
 
52
 
 
53
        if (!rc)
 
54
            return NULL;
54
55
    }
55
 
    
56
 
    mem = (void*) new char[size+(SIG_SIZE << 1)];
57
 
    
 
56
 
 
57
    mem = (void*) new char[size+ (SIG_SIZE << 1) ];
 
58
 
58
59
    /* Exception for new operator may be disabled, so.. */
59
60
    if (mem) {
60
 
        /* Apply signature when PJ_SAFE_POOL is set. It will move
61
 
         * "mem" pointer forward.
62
 
         */
63
 
        APPLY_SIG(mem, size);
 
61
        /* Apply signature when PJ_SAFE_POOL is set. It will move
 
62
         * "mem" pointer forward.
 
63
         */
 
64
        APPLY_SIG (mem, size);
64
65
    }
65
66
 
66
67
    return mem;
67
68
}
68
69
 
69
 
static void operator_delete(pj_pool_factory *factory, void *mem, pj_size_t size)
 
70
static void operator_delete (pj_pool_factory *factory, void *mem, pj_size_t size)
70
71
{
71
72
    PJ_CHECK_STACK();
72
73
 
73
 
    if (factory->on_block_free) 
74
 
        factory->on_block_free(factory, size);
75
 
    
 
74
    if (factory->on_block_free)
 
75
        factory->on_block_free (factory, size);
 
76
 
76
77
    /* Check and remove signature when PJ_SAFE_POOL is set. It will
77
78
     * move "mem" pointer backward.
78
79
     */
79
 
    REMOVE_SIG(mem, size);
 
80
    REMOVE_SIG (mem, size);
80
81
 
81
82
    /* Note that when PJ_SAFE_POOL is set, the actual size of the block
82
83
     * is size + SIG_SIZE*2.
83
84
     */
84
85
 
85
 
    char *p = (char*)mem;
 
86
    char *p = (char*) mem;
86
87
    delete [] p;
87
88
}
88
89
 
89
 
static void default_pool_callback(pj_pool_t *pool, pj_size_t size)
 
90
static void default_pool_callback (pj_pool_t *pool, pj_size_t size)
90
91
{
91
92
    PJ_CHECK_STACK();
92
 
    PJ_UNUSED_ARG(pool);
93
 
    PJ_UNUSED_ARG(size);
 
93
    PJ_UNUSED_ARG (pool);
 
94
    PJ_UNUSED_ARG (size);
94
95
 
95
 
    PJ_THROW(PJ_NO_MEMORY_EXCEPTION);
 
96
    PJ_THROW (PJ_NO_MEMORY_EXCEPTION);
96
97
}
97
98
 
98
 
PJ_DEF_DATA(pj_pool_factory_policy) pj_pool_factory_default_policy = 
99
 
{
 
99
PJ_DEF_DATA (pj_pool_factory_policy) pj_pool_factory_default_policy = {
100
100
    &operator_new,
101
101
    &operator_delete,
102
102
    &default_pool_callback,
103
103
    0
104
104
};
105
105
 
106
 
PJ_DEF(const pj_pool_factory_policy*) pj_pool_factory_get_default_policy(void)
 
106
PJ_DEF (const pj_pool_factory_policy*) pj_pool_factory_get_default_policy (void)
107
107
{
108
108
    return &pj_pool_factory_default_policy;
109
109
}
110
110
 
111
 
 
 
111
 
112
112
#endif  /* PJ_HAS_POOL_ALT_API */
113
113