3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file AliHLTDataBuffer.cxx
20 @author Matthias Richter
22 @brief Handling of Data Buffers for HLT components.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
35 #include "AliHLTDataBuffer.h"
36 #include "AliHLTConsumerDescriptor.h"
37 #include "AliHLTComponent.h"
41 //#include "AliHLTSystem.h"
43 /** ROOT macro for the implementation of ROOT specific class methods */
44 ClassImp(AliHLTDataBuffer)
46 AliHLTDataBuffer::AliHLTDataBuffer()
55 // see header file for class documentation
57 // refer to README to build package
59 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 fActiveConsumers.empty();
63 fReleasedConsumers.empty();
67 int AliHLTDataBuffer::fgNofInstances=0;
68 vector<AliHLTDataBuffer::AliHLTRawBuffer*> AliHLTDataBuffer::fgFreeBuffers;
69 vector<AliHLTDataBuffer::AliHLTRawBuffer*> AliHLTDataBuffer::fgActiveBuffers;
70 AliHLTUInt32_t AliHLTDataBuffer::fgMargin=1024;
71 AliHLTLogging AliHLTDataBuffer::fgLogging;
72 const Int_t AliHLTDataBuffer::fgkSafetyPatternSize=16;
73 const char AliHLTDataBuffer::fgkSafetyPattern[]={0x28, 0x63, 0x29, 0x4d, 0x52, 0x49, 0x43, 0x48, 0x54, 0x45, 0x52, 0x20, 0x32, 0x30, 0x30, 0x37};
75 AliHLTDataBuffer::~AliHLTDataBuffer()
77 // see header file for function documentation
78 if (--fgNofInstances<=0) {
81 CleanupConsumerList();
84 int AliHLTDataBuffer::SetConsumer(AliHLTComponent* pConsumer)
86 // see header file for function documentation
89 if (FindConsumer(pConsumer)) {
90 HLTWarning("consumer %s (%p) already set to data buffer %p", pConsumer->GetComponentID(), pConsumer, this);
92 AliHLTConsumerDescriptor* pDesc=new AliHLTConsumerDescriptor(pConsumer);
94 fConsumers.push_back(pDesc);
95 HLTDebug("set consumer %s (%p) to data buffer %p", pConsumer->GetComponentID(), pConsumer, this);
97 HLTError("memory allocation failed");
101 HLTError("invalid parameter: consumer component (nil)");
107 int AliHLTDataBuffer::FindMatchingDataBlocks(const AliHLTComponent* pConsumer, vector<AliHLTComponentDataType>* tgtList)
109 // see header file for function documentation
112 vector<AliHLTDataBuffer::AliHLTDataSegment> segments;
113 if ((iResult=FindMatchingDataSegments(pConsumer, segments))>=0) {
115 vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=segments.begin();
116 while (segment!=segments.end()) {
117 tgtList->push_back((*segment).fDataType);
121 iResult=segments.size();
129 int AliHLTDataBuffer::FindMatchingDataSegments(const AliHLTComponent* pConsumer, vector<AliHLTDataBuffer::AliHLTDataSegment>& tgtList)
131 // see header file for function documentation
134 // Matthias 26.09.2007 relax the restriction to matching data blocks
135 // all blocks are passed to the consumer, which is the policy also in
137 tgtList.assign(fSegments.begin(), fSegments.end());
138 iResult=tgtList.size();
142 vector<AliHLTComponentDataType> dtlist;
143 ((AliHLTComponent*)pConsumer)->GetInputDataTypes(dtlist);
144 vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=fSegments.begin();
145 while (segment!=fSegments.end()) {
146 vector<AliHLTComponentDataType>::iterator type=dtlist.begin();
147 while (type!=dtlist.end()) {
148 if ((*segment).fDataType==(*type) ||
149 (*type)==kAliHLTAnyDataType) {
150 tgtList.push_back(*segment);
164 int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponentBlockData* arrayBlockDesc, int iArraySize)
166 // see header file for function documentation
168 if (pConsumer && arrayBlockDesc) {
170 AliHLTConsumerDescriptor* pDesc=FindConsumer(pConsumer, fConsumers);
172 vector<AliHLTDataBuffer::AliHLTDataSegment> tgtList;
173 // Matthias 26.07.2007 AliHLTSystem should behave the same way as PubSub
174 // so it does not matter if there are matching data types or not, unless
175 // we implement such a check in PubSub
176 if ((iResult=FindMatchingDataSegments(pConsumer, tgtList))>=0) {
178 vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=tgtList.begin();
179 while (segment!=tgtList.end() && i<iArraySize) {
180 // fill the block data descriptor
181 arrayBlockDesc[i].fStructSize=sizeof(AliHLTComponentBlockData);
182 // the shared memory key is not used in AliRoot
183 arrayBlockDesc[i].fShmKey.fStructSize=sizeof(AliHLTComponentShmData);
184 arrayBlockDesc[i].fShmKey.fShmType=gkAliHLTComponentInvalidShmType;
185 arrayBlockDesc[i].fShmKey.fShmID=gkAliHLTComponentInvalidShmID;
186 // This models the behavior of PubSub.
187 // For incoming data blocks, fOffset must be ignored by the
188 // processing component. It is set for bookkeeping in the framework.
189 // fPtr always points to the beginning of the data.
190 arrayBlockDesc[i].fOffset=(*segment).fSegmentOffset;
191 AliHLTUInt8_t* pTgt=*fpBuffer;
192 pTgt+=(*segment).fSegmentOffset;
193 arrayBlockDesc[i].fPtr=reinterpret_cast<void*>(pTgt);
194 arrayBlockDesc[i].fSize=(*segment).fSegmentSize;
195 arrayBlockDesc[i].fDataType=(*segment).fDataType;
196 arrayBlockDesc[i].fSpecification=(*segment).fSpecification;
197 pDesc->SetActiveDataSegment(arrayBlockDesc[i].fOffset, arrayBlockDesc[i].fSize);
198 HLTDebug("component %p (%s) subscribed to segment #%d offset %d size %d data type %s %#x",
199 pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID(), i, arrayBlockDesc[i].fOffset,
200 arrayBlockDesc[i].fSize, (AliHLTComponent::DataType2Text(arrayBlockDesc[i].fDataType)).c_str(),
201 arrayBlockDesc[i].fSpecification);
205 // check whether there was enough space for the segments
206 if (i!=(int)tgtList.size()) {
207 HLTError("too little space in block descriptor array: required %d, available %d", tgtList.size(), iArraySize);
210 // move this consumer to the active list
211 if (ChangeConsumerState(pDesc, fConsumers, fActiveConsumers)>=0) {
212 HLTDebug("component %p (%s) subscribed to data buffer %p", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID(), this);
214 // TODO: cleanup the consumer descriptor correctly
215 memset(arrayBlockDesc, 0, iArraySize*sizeof(AliHLTComponentBlockData));
216 HLTError("can not activate consumer %p for data buffer %p", pConsumer, this);
221 HLTError("unresolved data segment(s) for component %p (%s)", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID());
225 HLTError("component %p is not a data consumer of data buffer %s", pConsumer, this);
229 // Matthias 26.07.2007 until now, data had to be present for successful subscription
230 // in order to be consistent with the PubSub framework, this restiction has been
232 //HLTError("data buffer %p is empty", this);
236 HLTError("invalid parameter");
242 int AliHLTDataBuffer::Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTComponent* pConsumer)
244 // see header file for function documentation
246 if (pBlockDesc && pConsumer) {
247 AliHLTConsumerDescriptor* pDesc=FindConsumer(pConsumer, fActiveConsumers);
249 if ((iResult=pDesc->CheckActiveDataSegment(pBlockDesc->fOffset, pBlockDesc->fSize))!=1) {
250 HLTWarning("data segment missmatch, component %p has not subscribed to a segment with offset %#x and size %d", pConsumer, pBlockDesc->fOffset, pBlockDesc->fSize);
251 // TODO: appropriate error handling, but so far optional
254 pDesc->ReleaseActiveDataSegment(pBlockDesc->fOffset, pBlockDesc->fSize);
255 pBlockDesc->fOffset=0;
256 pBlockDesc->fPtr=NULL;
259 if (pDesc->GetNofActiveSegments()==0) {
260 if ((iResult=ChangeConsumerState(pDesc, fActiveConsumers, fReleasedConsumers))>=0) {
261 if (GetNofActiveConsumers()==0 && GetNofPendingConsumers()==0) {
262 // this is the last consumer, reset the consumer list and release the raw buffer
266 HLTError("can not deactivate consumer %p for data buffer %p", pConsumer, this);
271 HLTWarning("component %p has currently not subscribed to the data buffer %p", pConsumer, this);
275 HLTError("inavalid parameter: pBlockDesc=%p pConsumer=%p", pBlockDesc, pConsumer);
281 AliHLTUInt8_t* AliHLTDataBuffer::GetTargetBuffer(int iMinSize)
283 // see header file for function documentation
284 AliHLTUInt8_t* pTargetBuffer=NULL;
285 if (fpBuffer!=NULL) {
286 HLTWarning("data buffer not properly reset, possible memory leak\n");
288 fpBuffer=CreateRawBuffer(iMinSize);
290 pTargetBuffer=*fpBuffer;
292 HLTError("can not create raw buffer");
294 return pTargetBuffer;
297 int AliHLTDataBuffer::SetSegments(AliHLTUInt8_t* pTgt, AliHLTComponentBlockData* arrayBlockData, int iSize)
299 // see header file for function documentation
301 if (pTgt && arrayBlockData && iSize>=0) {
303 if (*fpBuffer==pTgt) {
304 AliHLTDataBuffer::AliHLTDataSegment segment;
305 for (int i=0; i<iSize; i++) {
306 // This function has to model the behavior of PubSub
307 // For output blocks only the fOffset value is used, this must be the offset
308 // relative to the output pointer. fPtr must be either NULL or the output
310 if (arrayBlockData[i].fPtr==NULL ||
311 arrayBlockData[i].fPtr==*fpBuffer) {
312 if (arrayBlockData[i].fOffset+arrayBlockData[i].fSize<=reinterpret_cast<AliHLTUInt32_t>(fpBuffer)) {
313 segment.fSegmentOffset=arrayBlockData[i].fOffset;
314 segment.fSegmentSize=arrayBlockData[i].fSize;
315 segment.fDataType=arrayBlockData[i].fDataType;
316 segment.fSpecification=arrayBlockData[i].fSpecification;
317 fSegments.push_back(segment);
318 HLTDebug("set segment %s with size %d at offset %d", AliHLTComponent::DataType2Text(segment.fDataType).data(), segment.fSegmentSize, segment.fSegmentOffset);
320 HLTError("block data specification %#d (%s) exceeds size of data buffer", i, AliHLTComponent::DataType2Text(arrayBlockData[i].fDataType).data());
321 HLTError("block offset=%d, block size=%d, buffer size=%d", arrayBlockData[i].fOffset, arrayBlockData[i].fSize, reinterpret_cast<AliHLTUInt32_t>(fpBuffer));
325 HLTError("invalid pointer (%p) in block data specification (buffer %p size %d)."
326 "please note: for output blocks only the fOffset value is valid and must "
327 "be relative to the output buffer", arrayBlockData[i].fPtr, reinterpret_cast<void*>(fpBuffer), reinterpret_cast<AliHLTUInt32_t>(fpBuffer));
332 HLTError("this data buffer (%p) does not match the internal data buffer %p of raw buffer %p", pTgt, reinterpret_cast<void*>(fpBuffer), fpBuffer);
336 HLTFatal("internal data structur missmatch");
340 HLTError("invalid parameter: pTgtBuffer=%p arrayBlockData=%p", pTgt, arrayBlockData);
346 int AliHLTDataBuffer::IsEmpty()
348 // see header file for function documentation
349 int iResult=fpBuffer==NULL || GetNofSegments()==0;
353 int AliHLTDataBuffer::GetNofSegments()
355 // see header file for function documentation
356 int iResult=fSegments.size();
360 int AliHLTDataBuffer::GetNofConsumers()
362 // see header file for function documentation
363 int iResult=fConsumers.size() + GetNofActiveConsumers() + fReleasedConsumers.size();
367 int AliHLTDataBuffer::GetNofPendingConsumers()
369 // see header file for function documentation
370 int iResult=fConsumers.size();
374 int AliHLTDataBuffer::GetNofActiveConsumers()
376 // see header file for function documentation
377 int iResult=fActiveConsumers.size();
381 AliHLTDataBuffer::AliHLTRawBuffer* AliHLTDataBuffer::CreateRawBuffer(AliHLTUInt32_t size)
383 // see header file for function documentation
384 AliHLTRawBuffer* pRawBuffer=NULL;
385 unsigned int reqSize=size+fgkSafetyPatternSize;
386 vector<AliHLTRawBuffer*>::iterator buffer=fgFreeBuffers.begin();
387 while (buffer!=fgFreeBuffers.end() && pRawBuffer==NULL) {
388 if ((*buffer)->CheckSize(reqSize)) {
389 // assign this element
391 pRawBuffer->UseBuffer(size);
392 fgFreeBuffers.erase(buffer);
393 fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "raw buffer container %p provided for request of %d bytes (total %d available in buffer %p)", pRawBuffer, size, pRawBuffer->GetTotalSize(), reinterpret_cast<void*>(pRawBuffer));
394 fgActiveBuffers.push_back(pRawBuffer);
399 if (pRawBuffer==NULL) {
400 // no buffer found, create a new one
401 pRawBuffer=new AliHLTRawBuffer(reqSize);
403 if (reinterpret_cast<void*>(pRawBuffer)) {
404 pRawBuffer->UseBuffer(size);
405 fgActiveBuffers.push_back(pRawBuffer);
406 fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "new raw buffer %p of size %d created (container %p)", reinterpret_cast<void*>(pRawBuffer), pRawBuffer->GetTotalSize(), pRawBuffer);
410 fgLogging.Logging(kHLTLogError, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "memory allocation failed");
413 fgLogging.Logging(kHLTLogError, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "memory allocation failed");
416 if (pRawBuffer!=NULL && fgkSafetyPatternSize>0) {
417 //fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "writing safety pattern to %p offset %d", reinterpret_cast<void*>(*buffer), reinterpret_cast<AliHLTUInt32_t>(*buffer));
418 int res=pRawBuffer->WritePattern(fgkSafetyPattern, fgkSafetyPatternSize);
424 int AliHLTDataBuffer::ReleaseRawBuffer(AliHLTRawBuffer* pBuffer)
426 // see header file for function documentation
429 vector<AliHLTRawBuffer*>::iterator buffer=fgActiveBuffers.begin();
430 while (buffer!=fgActiveBuffers.end() && (*buffer)!=pBuffer) {
433 if (buffer!=fgActiveBuffers.end()) {
434 if (fgkSafetyPatternSize>0) {
435 //fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "comparing safety pattern at %p offset %d", reinterpret_cast<void*>(*buffer), reinterpret_cast<AliHLTUInt32_t>(*buffer));
436 if ((*buffer)->CheckPattern(fgkSafetyPattern, fgkSafetyPatternSize)) {
437 fgLogging.Logging(kHLTLogFatal, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "component has written beyond end of data buffer %p size %d", reinterpret_cast<void*>(*buffer), reinterpret_cast<AliHLTUInt32_t>(*buffer));
441 fgFreeBuffers.push_back(*buffer);
442 fgActiveBuffers.erase(buffer);
444 fgLogging.Logging(kHLTLogWarning, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "can not find raw buffer container %p in the list of active containers", pBuffer);
448 fgLogging.Logging(kHLTLogError, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "invalid parameter");
455 int AliHLTDataBuffer::DeleteRawBuffers()
457 // see header file for function documentation
459 vector<AliHLTRawBuffer*>::iterator buffer=fgFreeBuffers.begin();
460 while (buffer!=fgFreeBuffers.end()) {
462 fgFreeBuffers.erase(buffer);
463 buffer=fgFreeBuffers.begin();
465 buffer=fgActiveBuffers.begin();
466 while (buffer!=fgActiveBuffers.end()) {
467 fgLogging.Logging(kHLTLogWarning, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "request to delete active raw buffer container (raw buffer %p, size %d)", reinterpret_cast<void*>(*buffer), (*buffer)->GetTotalSize());
469 fgActiveBuffers.erase(buffer);
470 buffer=fgActiveBuffers.begin();
475 AliHLTConsumerDescriptor* AliHLTDataBuffer::FindConsumer(const AliHLTComponent* pConsumer, vector<AliHLTConsumerDescriptor*> &list) const
477 // see header file for function documentation
478 AliHLTConsumerDescriptor* pDesc=NULL;
479 vector<AliHLTConsumerDescriptor*>::iterator desc=list.begin();
480 while (desc!=list.end() && pDesc==NULL) {
481 if ((pConsumer==NULL || (*desc)->GetComponent()==pConsumer)) {
489 int AliHLTDataBuffer::ResetDataBuffer()
491 // see header file for function documentation
493 AliHLTRawBuffer* pBuffer=fpBuffer;
496 // cleanup consumer states
497 vector<AliHLTConsumerDescriptor*>::iterator desc;
498 // if (GetNofPendingConsumers()>0) {
499 // desc=fConsumers.begin();
500 // while (desc!=fConsumers.end()) {
501 // AliHLTComponent* pComp=(*desc)->GetComponent();
502 // HLTError("internal error: consumer %p (%s %p) did not get data from data buffer %p", *desc, pComp?pComp->GetComponentID():"", pComp, this);
506 desc=fReleasedConsumers.begin();
507 while (desc!=fReleasedConsumers.end()) {
508 AliHLTConsumerDescriptor* pDesc=*desc;
509 fReleasedConsumers.erase(desc);
510 desc=fReleasedConsumers.begin();
511 fConsumers.push_back(pDesc);
513 desc=fActiveConsumers.begin();
514 while (desc!=fActiveConsumers.end()) {
515 AliHLTConsumerDescriptor* pDesc=*desc;
516 HLTWarning("consumer %p was not released", pDesc);
517 fActiveConsumers.erase(desc);
518 desc=fActiveConsumers.begin();
519 fConsumers.push_back(pDesc);
523 vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=fSegments.begin();
524 while (segment!=fSegments.end()) {
525 fSegments.erase(segment);
526 segment=fSegments.begin();
529 // cleanup raw buffer
531 ReleaseRawBuffer(pBuffer);
536 int AliHLTDataBuffer::Reset()
538 // see header file for function documentation
539 return ResetDataBuffer();
542 // this is the version which works on lists of components instead of consumer descriptors
543 // int AliHLTDataBuffer::ChangeConsumerState(AliHLTComponent* pConsumer, vector<AliHLTComponent*> &srcList, vector<AliHLTComponent*> &tgtList)
547 // vector<AliHLTComponent*>::iterator desc=srcList.begin();
548 // while (desc!=srcList.end()) {
549 // if ((*desc)==pConsumer) {
550 // srcList.erase(desc);
551 // tgtList.push_back(pConsumer);
556 // if (desc==srcList.end()) {
557 // HLTError("can not find consumer component %p in list", pConsumer);
561 // HLTError("invalid parameter");
567 int AliHLTDataBuffer::ChangeConsumerState(AliHLTConsumerDescriptor* pDesc, vector<AliHLTConsumerDescriptor*> &srcList, vector<AliHLTConsumerDescriptor*> &tgtList)
569 // see header file for function documentation
572 vector<AliHLTConsumerDescriptor*>::iterator desc=srcList.begin();
573 while (desc!=srcList.end()) {
574 if ((*desc)==pDesc) {
576 tgtList.push_back(pDesc);
583 HLTError("can not find consumer descriptor %p in list", pDesc);
586 HLTError("invalid parameter");
592 int AliHLTDataBuffer::CleanupConsumerList()
594 // see header file for function documentation
597 vector<AliHLTConsumerDescriptor*>::iterator desc=fConsumers.begin();
598 while (desc!=fConsumers.end()) {
600 fConsumers.erase(desc);
601 desc=fConsumers.begin();
606 int AliHLTDataBuffer::FindConsumer(AliHLTComponent* pConsumer, int bAllLists)
608 // see header file for function documentation
609 vector<AliHLTConsumerDescriptor*>::iterator desc=fConsumers.begin();
610 while (desc!=fConsumers.end()) {
611 if ((*desc)->GetComponent()==pConsumer)
615 if (bAllLists==0) return 0;
617 desc=fActiveConsumers.begin();
618 while (desc!=fActiveConsumers.end()) {
619 if ((*desc)->GetComponent()==pConsumer)
623 desc=fReleasedConsumers.begin();
624 while (desc!=fReleasedConsumers.end()) {
625 if ((*desc)->GetComponent()==pConsumer)
632 AliHLTDataBuffer::AliHLTRawBuffer::AliHLTRawBuffer(AliHLTUInt32_t size)
636 fPtr(static_cast<AliHLTUInt8_t*>(malloc(size)))
638 // see header file for class documentation
640 // refer to README to build package
642 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
649 AliHLTDataBuffer::AliHLTRawBuffer::~AliHLTRawBuffer()
659 int AliHLTDataBuffer::AliHLTRawBuffer::operator==(void* ptr) const
661 // see header file for function documentation
662 return fPtr == static_cast<AliHLTUInt8_t*>(ptr);
665 int AliHLTDataBuffer::AliHLTRawBuffer::operator<=(void* ptr) const
667 // see header file for function documentation
668 int iResult=fPtr <= static_cast<AliHLTUInt8_t*>(ptr);
669 //printf("%p: %p <= %p (%d)\n", this, fPtr, ptr, iResult);
673 int AliHLTDataBuffer::AliHLTRawBuffer::operator>(void* ptr) const
675 // see header file for function documentation
676 int iResult=fPtr+fSize > static_cast<AliHLTUInt8_t*>(ptr);
677 //printf("%p: %p + %d > %p (%d)\n", this, fPtr, fSize, ptr, iResult);
681 int AliHLTDataBuffer::AliHLTRawBuffer::operator-(void* ptr) const
683 // see header file for function documentation
684 return static_cast<int>(static_cast<AliHLTUInt8_t*>(ptr)-fPtr);
687 AliHLTUInt8_t* AliHLTDataBuffer::AliHLTRawBuffer::UseBuffer(AliHLTUInt32_t size)
689 // see header file for function documentation
690 if (size>0 && CheckSize(size)) {
697 int AliHLTDataBuffer::AliHLTRawBuffer::CheckSize(AliHLTUInt32_t size) const
699 // see header file for function documentation
700 return fTotalSize>=size && ((fTotalSize-size)<fgMargin);
703 int AliHLTDataBuffer::AliHLTRawBuffer::Reset()
705 // see header file for function documentation
709 int AliHLTDataBuffer::AliHLTRawBuffer::WritePattern(const char* pattern, int size)
711 // see header file for function documentation
713 if (pattern!=NULL && size>0) {
714 if (fSize+size<=fTotalSize) {
715 memcpy(((char*)fPtr)+fSize, pattern, size);
724 int AliHLTDataBuffer::AliHLTRawBuffer::CheckPattern(const char* pattern, int size) const
726 // see header file for function documentation
728 if (pattern!=NULL && size>0) {
729 if (fSize+size<=fTotalSize) {
730 iResult=memcmp(((char*)fPtr)+fSize, pattern, size)!=0;