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

Function PAG_add_header_entry

src/jrd/pag.cpp:338–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336
337
338bool PAG_add_header_entry(thread_db* tdbb, header_page* header,
339 USHORT type, USHORT len, const UCHAR* entry)
340{
341/***********************************************
342 *
343 * P A G _ a d d _ h e a d e r _ e n t r y
344 *
345 ***********************************************
346 *
347 * Functional description
348 * Add an entry to header page.
349 * This will be used mainly for the shadow header page and adding
350 * secondary files.
351 * Will not follow to hdr_next_page
352 * Will not journal changes made to page. => obsolete
353 * RETURNS
354 * true - modified page
355 * false - nothing done
356 * CVC: Nobody checks the result of this function!
357 *
358 **************************************/
359 SET_TDBB(tdbb);
360 Database* dbb = tdbb->getDatabase();
361 CHECK_DBB(dbb);
362
363 err_post_if_database_is_readonly(dbb);
364
365 UCHAR* p = header->hdr_data;
366 while (*p != HDR_end && *p != type)
367 p += 2u + p[1];
368
369 if (*p != HDR_end)
370 return false;
371
372 // We are at HDR_end, add the entry
373
374 const int free_space = dbb->dbb_page_size - header->hdr_end;
375
376 if (free_space > (2 + len))
377 {
378 fb_assert(type <= MAX_UCHAR);
379 fb_assert(len <= MAX_UCHAR);
380 *p++ = static_cast<UCHAR>(type);
381 *p++ = static_cast<UCHAR>(len);
382
383 if (len)
384 {
385 if (entry) {
386 memcpy(p, entry, len);
387 }
388 else {
389 memset(p, 0, len);
390 }
391 p += len;
392 }
393
394 *p = HDR_end;
395

Callers 3

CCH_write_all_shadowsFunction · 0.85
SDW_add_fileFunction · 0.85
PAG_add_fileFunction · 0.85

Calls 4

SET_TDBBFunction · 0.85
CHECK_DBBFunction · 0.85
getDatabaseMethod · 0.80

Tested by

no test coverage detected