struct _subtable_data { int usecount; }; struct _table_data { unsigned char *table; struct _subtable_data subtable[64]; }; void reallocate_subtable(struct _table_data *tabledata, unsigned char subentry) { unsigned char subindex = subentry - (256 - 64); if (tabledata->subtable[subindex].usecount <= 0) osd_die(); } void release_subtable(struct _table_data *tabledata, unsigned char subentry) { unsigned char subindex = subentry - (256 - 64); if (tabledata->subtable[subindex].usecount <= 0) osd_die(); } void install_mem_handler( int end, char *handler_name) { int lmirrorbits; int hmirrorbits; int lmirrorcount; int hmirrorcount; struct _table_data *tabledata; char prev_entry; int cur_index; int prev_index; for (; hmirrorcount < (1 << hmirrorbits); hmirrorcount++) { int hmirrorbase = 0; if (cur_index == ((end + hmirrorbase) >> (32 - 18))) { if (hmirrorcount != 0 && prev_entry == tabledata->table[cur_index]) { if (tabledata->table[cur_index] >= (256 - 64)) release_subtable(tabledata, tabledata-> table[cur_index]); if (tabledata->table[prev_index] >= (256 - 64)) reallocate_subtable(tabledata, tabledata-> table[prev_index]); } } for (lmirrorcount = 0; lmirrorcount < (1 << lmirrorbits); lmirrorcount++) ; } }