]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCASliceOutput.cxx
Coding violations
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCASliceOutput.cxx
1 // @(#) $Id$
2 // **************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project          *
4 // ALICE Experiment at CERN, All rights reserved.                           *
5 //                                                                          *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 //                  Ivan Kisel <kisel@kip.uni-heidelberg.de>                *
8 //                  for The ALICE HLT Project.                              *
9 //                                                                          *
10 // Permission to use, copy, modify and distribute this software and its     *
11 // documentation strictly for non-commercial purposes is hereby granted     *
12 // without fee, provided that the above copyright notice appears in all     *
13 // copies and that both the copyright notice and this permission notice     *
14 // appear in the supporting documentation. The authors make no claims       *
15 // about the suitability of this software for any purpose. It is            *
16 // provided "as is" without express or implied warranty.                    *
17 //                                                                          *
18 //***************************************************************************
19
20 #include "AliHLTTPCCASliceOutput.h"
21 #include "MemoryAssignmentHelpers.h"
22
23
24 GPUhd() int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
25 {
26   // calculate the amount of memory [bytes] needed for the event
27
28   return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceOutTrack )*nOfTracks + sizeof(AliHLTTPCCASliceOutCluster)*nOfTrackClusters;
29 }
30
31 #ifndef HLTCA_GPUCODE
32
33 inline void AssignNoAlignment( int &dst, int &size, int count )
34 {
35   // assign memory to the pointer dst
36   dst = size;
37   size = dst + count ;
38 }
39
40
41 void AliHLTTPCCASliceOutput::Allocate(AliHLTTPCCASliceOutput* &ptrOutput, int nTracks, int nTrackHits, outputControlStruct* outputControl)
42 {
43         //Allocate All memory needed for slice output
44   const int memsize =  EstimateSize(nTracks, nTrackHits);
45
46   if (outputControl->fOutputPtr)
47   {
48     if (outputControl->fOutputMaxSize < memsize)
49       {
50         outputControl->fEndOfSpace = 1;
51         ptrOutput = NULL;
52         return;
53       }
54     ptrOutput = (AliHLTTPCCASliceOutput*) outputControl->fOutputPtr;
55     outputControl->fOutputPtr += memsize;
56     outputControl->fOutputMaxSize -= memsize;
57   }
58   else
59     {
60       if (ptrOutput) free(ptrOutput);
61       ptrOutput = (AliHLTTPCCASliceOutput*) malloc(memsize);
62     }
63   ptrOutput->SetMemorySize(memsize);
64 }
65 #endif