// Initialize a single central free list. void runtime·MCentral_Init(MCentral *c, int32 sizeclass) { c->sizeclass = sizeclass; runtime·MSpanList_Init(&c->nonempty); runtime·MSpanList_Init(&c->empty); }
// Initialize the heap; fetch memory using alloc. void runtime·MHeap_Init(MHeap *h, void *(*alloc)(uintptr)) { uint32 i; runtime·FixAlloc_Init(&h->spanalloc, sizeof(MSpan), alloc, RecordSpan, h); runtime·FixAlloc_Init(&h->cachealloc, sizeof(MCache), alloc, nil, nil); // h->mapcache needs no init for(i=0; i<nelem(h->free); i++) runtime·MSpanList_Init(&h->free[i]); runtime·MSpanList_Init(&h->large); for(i=0; i<nelem(h->central); i++) runtime·MCentral_Init(&h->central[i], i); }
// Initialize the heap; fetch memory using alloc. void runtime·MHeap_Init(MHeap *h) { uint32 i; runtime·FixAlloc_Init(&h->spanalloc, sizeof(MSpan), RecordSpan, h, &mstats.mspan_sys); runtime·FixAlloc_Init(&h->cachealloc, sizeof(MCache), nil, nil, &mstats.mcache_sys); runtime·FixAlloc_Init(&h->specialfinalizeralloc, sizeof(SpecialFinalizer), nil, nil, &mstats.other_sys); runtime·FixAlloc_Init(&h->specialprofilealloc, sizeof(SpecialProfile), nil, nil, &mstats.other_sys); // h->mapcache needs no init for(i=0; i<nelem(h->free); i++) { runtime·MSpanList_Init(&h->free[i]); runtime·MSpanList_Init(&h->busy[i]); } runtime·MSpanList_Init(&h->freelarge); runtime·MSpanList_Init(&h->busylarge); for(i=0; i<nelem(h->central); i++) runtime·MCentral_Init(&h->central[i].mcentral, i); }