MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / renewBuffer

Method renewBuffer

src/burp/BurpTasks.cpp:351–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351IOBuffer* BackupRelationTask::renewBuffer(BurpGlobals* tdgbl)
352{
353 fb_assert(!tdgbl->master);
354
355 Item* item = static_cast<Item*>(tdgbl->taskItem);
356 fb_assert(item);
357 if (!item)
358 return NULL;
359
360 BackupRelationTask* task = item->getBackupTask();
361
362 IOBuffer* oldBuf = item->m_buffer;
363 IOBuffer* newBuf = task->getCleanBuffer(*item);
364
365 if (!newBuf)
366 {
367 if (oldBuf && task->m_stop)
368 oldBuf->unlock();
369
370 throw LongJump();
371 }
372
373 FB_SIZE_T used = 0;
374 UCHAR* const p = newBuf->getBuffer();
375
376 if (oldBuf)
377 {
378 fb_assert(tdgbl->mvol_io_buffer == oldBuf->getBuffer());
379 fb_assert(tdgbl->gbl_io_ptr == tdgbl->mvol_io_buffer + oldBuf->getSize());
380 fb_assert(tdgbl->gbl_io_cnt <= 0);
381
382 if (oldBuf->getRecs() > 0)
383 {
384 used = tdgbl->mvol_io_data - tdgbl->mvol_io_buffer;
385 oldBuf->setUsed(used);
386
387 used = newBuf->getSize() - used;
388 memcpy(p, tdgbl->mvol_io_data, used);
389 }
390 else
391 {
392 oldBuf->setUsed(oldBuf->getSize());
393 oldBuf->linkNext(newBuf);
394 }
395
396 task->putDirtyBuffer(oldBuf);
397 }
398
399 item->m_buffer = newBuf;
400 tdgbl->mvol_io_buffer = p; // buffer start
401 tdgbl->mvol_io_data = p; // current record start
402 tdgbl->gbl_io_ptr = p + used; // current write pointer
403 tdgbl->gbl_io_cnt = newBuf->getSize() - used; // space left at buffer
404
405 return newBuf;
406}
407
408void BackupRelationTask::releaseBuffer(Item& item)

Callers

nothing calls this directly

Calls 15

LongJumpClass · 0.85
raiseFunction · 0.85
getCleanBufferMethod · 0.80
getRecsMethod · 0.80
setUsedMethod · 0.80
linkNextMethod · 0.80
putDirtyBufferMethod · 0.80
putCleanBufferMethod · 0.80
getDirtyBufferMethod · 0.80
getBackupTaskMethod · 0.45
unlockMethod · 0.45
getBufferMethod · 0.45

Tested by

no test coverage detected