MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / eedi2_aligned_malloc

Function eedi2_aligned_malloc

libhb/eedi2.c:32–48  ·  view source on GitHub ↗

* Analog of _aligned_malloc * @param size Size of memory being pointed to * @param align_size Size of memory chunks to align to (must be power of 2) */

Source from the content-addressed store, hash-verified

30 * @param align_size Size of memory chunks to align to (must be power of 2)
31 */
32void *eedi2_aligned_malloc( size_t size, size_t align_size )
33{
34 char * ptr, * ptr2, * aligned_ptr;
35 int align_mask = align_size - 1;
36
37 ptr = (char *)malloc( size + align_size + sizeof( int ) );
38 if( ptr==NULL ) return( NULL );
39
40 ptr2 = ptr + sizeof( int );
41 aligned_ptr = ptr2 + ( align_size - ( (size_t)ptr2 & align_mask ) );
42
43
44 ptr2 = aligned_ptr - sizeof( int );
45 *( (int *)ptr2 ) = (int)( aligned_ptr - ptr );
46
47 return( aligned_ptr );
48}
49
50/**
51 * Analog of _aligned_free

Callers 1

hb_decomb_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected