@@ -34,68 +34,11 @@ void *qt_realloc(void *ptr, size_t size) { return realloc(ptr, size); }
34
34
void qt_internal_alignment_init (void ) { _pagesize = getpagesize (); }
35
35
36
36
void * qt_internal_aligned_alloc (size_t alloc_size , uint_fast16_t alignment ) {
37
- void * ret ;
38
-
39
- assert (alloc_size > 0 );
40
- switch (alignment ) {
41
- case 0 : ret = MALLOC (alloc_size ); break ;
42
- case 16 :
43
- case 8 :
44
- case 4 :
45
- case 2 : ret = MALLOC (alloc_size ); break ;
46
- default :
47
- #if defined(HAVE_WORKING_VALLOC )
48
- if (alignment == pagesize ) {
49
- ret = valloc (alloc_size );
50
- break ;
51
- }
52
- #elif defined(HAVE_PAGE_ALIGNED_MALLOC )
53
- if (alignment == pagesize ) {
54
- ret = MALLOC (alloc_size );
55
- break ;
56
- }
57
- #endif
58
- #if defined(HAVE_MEMALIGN )
59
- ret = memalign (alignment , alloc_size );
60
- #elif defined(HAVE_POSIX_MEMALIGN )
61
- posix_memalign (& (ret ), alignment , alloc_size );
62
- #else
63
- {
64
- uint8_t * tmp = MALLOC ((alloc_size + alignment - 1 ) + sizeof (void * ));
65
- if (!tmp ) { return NULL ; }
66
- ret = (void * )(((uintptr_t )(tmp + sizeof (void * ) + alignment - 1 )) &
67
- ~(alignment - 1 ));
68
- * ((void * * )ret - 1 ) = tmp ;
69
- } break ;
70
- #endif /* if defined(HAVE_MEMALIGN) */
71
- }
72
- assert (ret );
73
- assert (((uintptr_t )ret & (alignment - 1 )) == 0 );
74
- return ret ;
37
+ return aligned_alloc ((size_t ) alignment , alloc_size );
75
38
}
76
39
77
40
void qt_internal_aligned_free (void * ptr , uint_fast16_t alignment ) {
78
- assert (ptr );
79
- switch (alignment ) {
80
- case 0 : qt_free (ptr ); break ;
81
- case 16 :
82
- case 8 :
83
- case 4 :
84
- case 2 : qt_free (ptr ); break ;
85
- default :
86
- #if defined(HAVE_WORKING_VALLOC ) || defined(HAVE_PAGE_ALIGNED_MALLOC )
87
- if (alignment == pagesize ) {
88
- qt_free (ptr );
89
- break ;
90
- }
91
- #endif
92
- #if defined(HAVE_MEMALIGN ) || defined(HAVE_POSIX_MEMALIGN )
93
- qt_free (ptr );
94
- #else
95
- assert ((uintptr_t ) * ((void * * )ptr - 1 ) > 4096 );
96
- qt_free (* ((void * * )ptr - 1 ));
97
- #endif
98
- }
41
+ qt_free (ptr );
99
42
}
100
43
101
44
/* vim:set expandtab: */
0 commit comments