Code: Select all
char *buffer1;
char *buffer2;
InitMemoryManager();
AllocPages(3, &buffer1);
AllocPages(10, &buffer2);
vid.printf("Address of *Buffer1: %x\n",*buffer1);
vid.printf("Address of *Buffer2: %x\n",*buffer2);
vid.printf("Address of &Buffer1: %x\n",&buffer1);
vid.printf("Address of &Buffer2: %x\n",&buffer2);
Originally I had AllocPages return a long that was assigned in a manor similar to
Code: Select all
buffer1 = (char *) AllocPages(3);
Code: Select all
long AllocPages(int size, char **s)
{
int pages = size;
int i=0;
int count=0;
int t=0;
vid.printf("Attempting to Allocate Ram for %d pages...\n",pages);
if (pages > TotalFreePages) return 0; /* Chunk to Big to Allocate */
vid.printf("Enter Search Routine...\n");
for (i=0;i < TotalPages;i++) /* Loop through the Page Bit Map */
{
if (MemBitMap[i] == 0) /* If Bit map index is 0 */
{
for (count = 0; count < pages; count++) /* Enter an Inner loop to find Consecutive Pages */
if (MemBitMap[i+count] != 0) break; /* if this page isn't free stop checking */
vid.printf("MemBitMap[i] = 0 @ i =%d\n",i);
vid.printf("Count = %d\n",count);
if (count == pages) /* After the loop, are the pages free equal to what we are looking for? */
{
for (t=0; t<=count; t++) /* Lets Declare this chain of Pages Allocated */
{
MemBitMap[i+t] = 1; /* Set it to Non-Zero*/
}
TotalFreePages -= count; /* Adjust Number of Free Pages after alloc */
vid.printf("Return Value = %d(%x)\n",i*4096,i*4096);
s = (char **)(i*4096);
return 1; /* Return the Location of the Starting Page */
}
}
}
return 0;
}
Thanks for the help,
Rich P.