GCC Code Coverage Report


Directory: ./
File: src/phoenix_allocAlignedVector.cpp
Date: 2025-08-06 14:32:39
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 2 2 100.0%
Branches: 2 2 100.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include <stdlib.h>
8 #include <stdint.h> //pour uintptr_t
9 #include <stdio.h>
10
11 #include "phoenix_allocAlignedVector.h"
12
13 #ifndef __APPLE__
14 # include <malloc.h>
15 #endif
16
17 #ifdef __APPLE__
18 ///Alloc an aligned vector
19 /** @param sizeOfVectorInBytes : size of the vector xe want to allocate
20 * @param alignementInBytes : alignement of the vector we want to allocate
21 * @return aligned pointor of the vector
22 */
23 void * memalign(size_t alignementInBytes,size_t sizeOfVectorInBytes){
24 void * ptr = NULL;
25 posix_memalign(&ptr, alignementInBytes, sizeOfVectorInBytes);
26 return ptr;
27 }
28 #endif
29
30 ///Alloc an aligned vector
31 /** @param sizeOfVectorInBytes : size of the vector xe want to allocate
32 * @param alignementInBytes : alignement of the vector we want to allocate
33 * @return aligned pointor of the vector
34 */
35 1 void* phoenix_allocAlignedTab(size_t sizeOfVectorInBytes, size_t alignementInBytes){
36 1 return memalign(alignementInBytes, sizeOfVectorInBytes);
37 }
38
39 ///Free the aligned vector
40 /** @param ptr : pointor we want to free
41 *
42 * Usage :
43 * void* mem = phoenix_allocAlignedVector(alignedVector, sizeOfVectorInBytes, alignementInBytes);
44 * ...
45 * Using of alignedVector pointor
46 * ...
47 * phoenix_freeAlignedVector(mem);
48 */
49 2 void phoenix_freeAlignedVector(void* ptr){
50
2/2
✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→4) taken 1 times.
2 if(ptr == NULL) return;
51 1 free(ptr);
52 }
53
54
55
56
57