| 336 | |
| 337 | |
| 338 | bool 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 |
no test coverage detected