MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / Alloc2

Method Alloc2

ngstd/blockalloc.cpp:50–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49
50 void * BlockAllocator :: Alloc2 ()
51 {
52 // cout << "blockallocator, alloc2 size = " << size << ", blocks = " << blocks << endl;
53 // return new char[size];
54 // if (!freelist)
55 {
56 char * hcp = new char [size * blocks];
57 mt.Alloc(size * blocks);
58 bablocks.Append (hcp);
59 bablocks.Last() = hcp;
60
61 for (unsigned int i = 0; i < blocks-1; i++)
62 *(void**)&(hcp[i * size]) = &(hcp[ (i+1) * size]);
63 *(void**)&(hcp[(blocks-1)*size]) = NULL;
64 freelist = hcp;
65 }
66 /*
67 void * p = freelist;
68 freelist = *(void**)freelist;
69 return p;
70 */
71 return (void*)freelist;
72 }
73
74
75 void BlockAllocator :: Free (void * p)

Callers

nothing calls this directly

Calls 2

AllocMethod · 0.80
AppendMethod · 0.45

Tested by

no test coverage detected