~ubuntu-branches/ubuntu/saucy/blender/saucy-proposed

« back to all changes in this revision

Viewing changes to extern/libopenjpeg/opj_malloc.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2005, Herv� Drolon, FreeImage Team
 
2
 * Copyright (c) 2005, Herve Drolon, FreeImage Team
3
3
 * Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
4
4
 * All rights reserved.
5
5
 *
45
45
@param size Bytes to allocate
46
46
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
47
47
*/
 
48
#ifdef ALLOC_PERF_OPT
 
49
void * OPJ_CALLCONV opj_malloc(size_t size);
 
50
#else
48
51
#define opj_malloc(size) malloc(size)
 
52
#endif
49
53
 
50
54
/**
51
55
Allocate a memory block with elements initialized to 0
53
57
@param size Bytes per block to allocate
54
58
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
55
59
*/
 
60
#ifdef ALLOC_PERF_OPT
 
61
void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements);
 
62
#else
56
63
#define opj_calloc(num, size) calloc(num, size)
 
64
#endif
57
65
 
58
66
/**
59
67
Allocate memory aligned to a 16 byte boundry
61
69
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
62
70
*/
63
71
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
64
 
#ifdef WIN32
 
72
#ifdef _WIN32
65
73
        /* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
66
74
        #ifdef __GNUC__
67
75
                #include <mm_malloc.h>
72
80
                        #define HAVE_MM_MALLOC
73
81
                #endif
74
82
        #endif
75
 
#else /* Not WIN32 */
 
83
#else /* Not _WIN32 */
76
84
        #if defined(__sun)
77
 
                        #define HAVE_MEMALIGN
78
 
                #elif defined(__GNUC__)
79
 
                        #if !defined(__APPLE__) && !defined(__FreeBSD__)
80
 
                            #define HAVE_MEMALIGN
81
 
                            #include <malloc.h>
82
 
                        #endif
83
 
                /* Linux x86_64 and OSX always align allocations to 16 bytes */
84
 
                #elif !defined(__amd64__) && !defined(__APPLE__)        
85
 
                        /* FIXME: Yes, this is a big assumption */
86
 
                        #define HAVE_POSIX_MEMALIGN
 
85
                #define HAVE_MEMALIGN
 
86
        /* Linux x86_64 and OSX always align allocations to 16 bytes */
 
87
        #elif !defined(__amd64__) && !defined(__APPLE__)        
 
88
                #define HAVE_MEMALIGN
 
89
                #include <malloc.h>                     
87
90
        #endif
88
91
#endif
89
92
 
90
 
 
91
 
 
92
93
#define opj_aligned_malloc(size) malloc(size)
93
94
#define opj_aligned_free(m) free(m)
94
95
 
120
121
        #define opj_aligned_free(m) free(m)
121
122
#endif
122
123
 
 
124
#ifdef ALLOC_PERF_OPT
 
125
        #undef opj_aligned_malloc
 
126
        #define opj_aligned_malloc(size) opj_malloc(size)
 
127
        #undef opj_aligned_free
 
128
        #define opj_aligned_free(m) opj_free(m)
 
129
#endif
 
130
 
123
131
/**
124
132
Reallocate memory blocks.
125
 
@param memblock Pointer to previously allocated memory block
126
 
@param size New size in bytes
 
133
@param m Pointer to previously allocated memory block
 
134
@param s New size in bytes
127
135
@return Returns a void pointer to the reallocated (and possibly moved) memory block
128
136
*/
 
137
#ifdef ALLOC_PERF_OPT
 
138
void * OPJ_CALLCONV opj_realloc(void * m, size_t s);
 
139
#else
129
140
#define opj_realloc(m, s) realloc(m, s)
 
141
#endif
130
142
 
131
143
/**
132
144
Deallocates or frees a memory block.
133
 
@param memblock Previously allocated memory block to be freed
 
145
@param m Previously allocated memory block to be freed
134
146
*/
 
147
#ifdef ALLOC_PERF_OPT
 
148
void OPJ_CALLCONV opj_free(void * m);
 
149
#else
135
150
#define opj_free(m) free(m)
 
151
#endif
136
152
 
137
153
#ifdef __GNUC__
138
154
#pragma GCC poison malloc calloc realloc free