]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCASliceOutput.cxx
coverity warning 10075 fixed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCASliceOutput.cxx
CommitLineData
4acc2401 1// @(#) $Id$
ce565086 2// **************************************************************************
fbb9b71b 3// This file is property of and copyright by the ALICE HLT Project *
d54804bf 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. *
ce565086 17// *
d54804bf 18//***************************************************************************
326c2d4b 19
4acc2401 20#include "AliHLTTPCCASliceOutput.h"
326c2d4b 21
f0bada7f 22int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
4acc2401 23{
24 // calculate the amount of memory [bytes] needed for the event
25
0f1f07c3 26 return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceOutTrack )*nOfTracks + sizeof(AliHLTTPCCASliceOutCluster)*nOfTrackClusters;
4acc2401 27}
326c2d4b 28
7be9b0d7 29#ifndef HLTCA_GPUCODE
b22af1bf 30
e65db743 31inline void AssignNoAlignment( int &dst, int &size, int count )
ef1d207e 32{
33 // assign memory to the pointer dst
e65db743 34 dst = size;
35 size = dst + count ;
ef1d207e 36}
6de2bc40 37
b22af1bf 38
d4594e7d 39void AliHLTTPCCASliceOutput::Allocate(AliHLTTPCCASliceOutput* &ptrOutput, int nTracks, int nTrackHits, outputControlStruct* outputControl)
b22af1bf 40{
41 //Allocate All memory needed for slice output
5cb6ddd4 42 const int memsize = EstimateSize(nTracks, nTrackHits);
43
d4594e7d 44 if (outputControl->fOutputPtr)
45 {
0f1f07c3 46 if (outputControl->fOutputMaxSize < memsize)
47 {
48 outputControl->fEndOfSpace = 1;
49 ptrOutput = NULL;
50 return;
51 }
52 ptrOutput = (AliHLTTPCCASliceOutput*) outputControl->fOutputPtr;
53 outputControl->fOutputPtr += memsize;
54 outputControl->fOutputMaxSize -= memsize;
d4594e7d 55 }
56 else
0f1f07c3 57 {
58 if (ptrOutput) free(ptrOutput);
59 ptrOutput = (AliHLTTPCCASliceOutput*) malloc(memsize);
60 }
d4594e7d 61 ptrOutput->SetMemorySize(memsize);
dc4788ec 62}
7be9b0d7 63#endif