Line data Source code
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 :
22 : int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
23 : {
24 : // calculate the amount of memory [bytes] needed for the event
25 :
26 0 : return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceOutTrack )*nOfTracks + sizeof(AliHLTTPCCASliceOutCluster)*nOfTrackClusters;
27 : }
28 :
29 : #ifndef HLTCA_GPUCODE
30 :
31 : inline void AssignNoAlignment( int &dst, int &size, int count )
32 : {
33 : // assign memory to the pointer dst
34 : dst = size;
35 : size = dst + count ;
36 : }
37 :
38 :
39 : void AliHLTTPCCASliceOutput::Allocate(AliHLTTPCCASliceOutput* &ptrOutput, int nTracks, int nTrackHits, outputControlStruct* outputControl)
40 : {
41 : //Allocate All memory needed for slice output
42 0 : const int memsize = EstimateSize(nTracks, nTrackHits);
43 :
44 0 : if (outputControl->fOutputPtr)
45 : {
46 0 : if (outputControl->fOutputMaxSize < memsize)
47 : {
48 0 : outputControl->fEndOfSpace = 1;
49 0 : ptrOutput = NULL;
50 0 : return;
51 : }
52 0 : ptrOutput = (AliHLTTPCCASliceOutput*) outputControl->fOutputPtr;
53 0 : outputControl->fOutputPtr += memsize;
54 0 : outputControl->fOutputMaxSize -= memsize;
55 0 : }
56 : else
57 : {
58 0 : if (ptrOutput) free(ptrOutput);
59 0 : ptrOutput = (AliHLTTPCCASliceOutput*) malloc(memsize);
60 : }
61 0 : ptrOutput->SetMemorySize(memsize);
62 0 : }
63 : #endif
|