FreedBlock* WriteTags(u8* p, size_t size) { FreedBlock* freedBlock = new(p) FreedBlock(s_headerId, size); (void)new(Footer(freedBlock)) FreedBlock(s_footerId, size); m_freeBlocks++; m_freeBytes += size; Validate(freedBlock); return freedBlock; }
void Validate(FreedBlock* freedBlock) const { if(!performSanityChecks) return; // the existence of freedBlock means our bookkeeping better have // records of at least that much memory. ENSURE(m_freeBlocks != 0); ENSURE(m_freeBytes >= freedBlock->Size()); freedBlock->Validate(s_headerId); Footer(freedBlock)->Validate(s_footerId); }
FreedBlock* WriteTags(u8* p, size_t size) { FreedBlock* freedBlock = (FreedBlock*)p; freedBlock->Setup(s_headerId, size); Footer(freedBlock)->Setup(s_footerId, size); m_freeBlocks++; m_freeBytes += size; Validate(freedBlock); return freedBlock; }
void RemoveTags(FreedBlock* freedBlock) { Validate(freedBlock); ENSURE(m_freeBlocks != 0); ENSURE(m_freeBytes >= freedBlock->Size()); m_freeBlocks--; m_freeBytes -= freedBlock->Size(); FreedBlock* footer = Footer(freedBlock); freedBlock->~FreedBlock(); footer->~FreedBlock(); }
//--------------------------------------------------------------------------- void File_Lyrics3::Read_Buffer_Continue() { if (Buffer_Size<20) return; Stream_Prepare(Stream_General); Header(); Lyrics(); Footer(); Finished(); }
//--------------------------------------------------------------------------- void File_Lyrics3v2::Data_Parse() { #define CASE_INFO(_NAME, _DETAIL) \ case Elements::_NAME : Element_Info1(_DETAIL); _NAME(); break; //Parsing switch (Element_Code) { CASE_INFO(AUT, "Lyrics Author Name"); CASE_INFO(CRC, "CRC"); CASE_INFO(EAL, "Extended Album name"); CASE_INFO(EAR, "Extended Artist name"); CASE_INFO(ETT, "Extended Track Title"); CASE_INFO(IMG, "Image location"); CASE_INFO(IND, "Indications field"); CASE_INFO(INF, "Additional information"); CASE_INFO(LYR, "Lyrics"); case (int64u)-1 : Footer(); break; default : Skip_XX(Element_Size, "Data"); } }
//--------------------------------------------------------------------------- void File_Lyrics3v2::Data_Parse() { #define ELEMENT_CASE(_NAME) \ case Lyrics3v2::_NAME : _NAME(); break; //Parsing switch (Element_Code) { ELEMENT_CASE(AUT); ELEMENT_CASE(CRC); ELEMENT_CASE(EAL); ELEMENT_CASE(EAR); ELEMENT_CASE(ETT); ELEMENT_CASE(IMG); ELEMENT_CASE(IND); ELEMENT_CASE(INF); ELEMENT_CASE(LYR); case 0xFFFFFFFF : Footer(); break; default : Skip_XX(Element_Size, "Data"); } }
int Bulletin() { bulletinASC = fopen("baddest.txt", "wt"); if (!bulletinASC) { printf("error at baddest.txt!\n"); exit(1); } bulletinANS = fopen("baddest.gfx", "wt"); if (!bulletinANS) { printf("error at baddest.ans!\n"); exit(1); } datafile = fopen("baddest.dat", "rb"); if (!datafile) { printf("error at baddest.dat!\n"); fclose(bulletinASC); fclose(bulletinANS); exit(1); } Header(); /* write header */ i = 0; while (!feof(datafile)) { i++; fread(&PMC, sizeof(Baddest), 1, datafile); if (feof(datafile)) break; /* if we have end of file detected, so last entry wont be dupe */ strcat(blt_username[i], PMC.User_Name); blt_megs[i] = 0; blt_megs[i] = PMC.Megs; blt_cps[i] = 0; if (PMC.Time != 0) { blt_cps[i] = PMC.Megs / PMC.Time; /* count CPS */ if (blt_cps[i] > max_cps) blt_cps[i] = 0; } blt_files[i] = 0; blt_files[i] = PMC.Files; blt_time[i] = 0; blt_time[i] = PMC.Time; strcpy(blt_date[i], PMC.Date); } maxuser = i; /* how many users */ /* sorting routine by Miz (c) PMC 1997. */ for (i = 1; i <= maxuser; i++) { userbyte_pos[i] = 1; for (x = 1; x <= maxuser; x++) { if (blt_megs[i] < blt_megs[x]) userbyte_pos[i]++; } } /* displaying the sorted by Miz (c) PMC 1997. */ while (Pos <= blt_total) { for (x = 1; x <= maxuser; x++) if (userbyte_pos[x] == Pos) { if (blt_megs[x] == 0) break; /* no more guys, break the loop */ sprintf(bigstring, "\n | %2d) %-18s|%5dmb | %7d |%5d |%5d | %s |", Pos, blt_username[x], blt_megs[x] / 1024 / 1024, blt_cps[x], blt_time[x] / 60, blt_files[x], blt_date[x]); fprintf(bulletinASC, bigstring); /* write datas. format will happen automatically. this is the ASC version */ sprintf(bigstring, "\n %s|%s %2d)%s %-18s%s|%s%5dmb %s|%s %7d %s|%s%5d %s|%s%5d %s|%s %s %s|", clr_frame, clr_pos, Pos, clr_uname, blt_username[x], clr_frame, clr_batch, blt_megs[x] / 1024 / 1024, clr_frame, clr_cps, blt_cps[x], clr_frame, clr_min, blt_time[x] / 60, clr_frame, clr_files, blt_files[x], clr_frame, clr_date, blt_date[x], clr_frame); fprintf(bulletinANS, bigstring); /* this is the ANSI version */ } Pos++; } /* bulletin write finished! */ Footer(); fclose(bulletinASC); fclose(bulletinANS); fclose(datafile); return 0; }
void Menu::Print (bool force_clear) { if (force_clear) { clear_screen = true; } if (clear_screen) { ClearScreen(); Header(); } if (offset < 0) { offset = 0; } int ofs = offset; PrintStatus(); if (current_status == 2) // Loading kernel { SetCursor (0, 0); printf ("\n"); return; } max_lines_on_screen = GetScreenHeight() - 9; lines = GetNumEntriesOfParent (current_parent); if (lines > max_lines_on_screen) { lines = max_lines_on_screen; } int line = 0; TextColor(BRIGHT, WHITE, BLACK); int width = GetScreenWidth(); if (b_clear_line) { clear_line = ""; for (int i = 0; i < width - 13 - 5; i++) { clear_line += " "; } } for (int i = 0; i < entries.size(); i++) { if (entries[i].id_parent == current_parent) { if (ofs > 0) { ofs--; } else { if (b_clear_line) { SetCursor (8, 6 + line); printf ("%s", clear_line.c_str()); } SetCursor (8, 6 + line); if (entries[i].menu_label.length() + 13 > width - 5) { string menu_label = entries[i].menu_label.substr (0, width - 13 - 5); printf ("%s: %s", entries[i].device.c_str() + 5, menu_label.c_str()); } else { printf ("%s: %s", entries[i].device.c_str() + 5, entries[i].menu_label.c_str()); } if (line == position) { current_entry = i; } line++; if (line > max_lines_on_screen) { break; } } } } if (entries.size() > 0) { PrintTimeout(); DrawCursor (width); } else { SetCursor (8, 6); printf ("No Linux has been found."); } if (clear_screen) { Footer(); SetCursor (0, 0); printf ("\n"); } b_clear_line = false; clear_screen = false; }