1

私はガベージコレクタを実装しなければならないCでこの問題を抱えています。完了するために 4 つの関数が与えられたという事実に固執しており、それらが互いにどのように接続されているかわかりません。どうすればいいのかわからない。これは私がこれまでに持っているものです:

void mygc() {
  //int **max = (int **) 0xbfffffffUL;   // the address of the top of the stack
  unsigned long stack_bottom;
  int **max =  (int **) GC_init();   // get the address of the bottom of the stack
  int* q;
  int **p = &q;    // the address of the bottom of the stack

  while (p < max) {
    //printf("0. p: %u, *p: %u max: %u\n",p,*p,max);
    mark(*p);
    p++;
  }

  //utilize sweep and coalesce (coalesce function already written)
}

void mark(int *p) {
  int i;
  int *ptr;
  //code here
}

void sweep(int *ptr) {
  // code here
}

int *isPtr(int *p) {  
 //return the pointer or NULL
  int *ptr = start;

  //code here
 }
4

1 に答える 1