comparison dmd/Array.d @ 191:52188e7e3fb5

Fixed deprecated features, now compiles with DMD2.058 Also changed Array allocation policy: Now doesn't reallocate but malloc's, followed by a memcpy (no free). (this fixes a crash while compiling druntime. Same bug in dmd)
author korDen@korDen-pc
date Sun, 25 Mar 2012 03:11:12 +0400
parents e3afd1303184
children
comparison
equal deleted inserted replaced
190:80660782bffe 191:52188e7e3fb5
65 final void reserve(uint nentries) 65 final void reserve(uint nentries)
66 { 66 {
67 //printf("Array::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes); 67 //printf("Array::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes);
68 if (allocdim - dim < nentries) { 68 if (allocdim - dim < nentries) {
69 allocdim = dim + nentries; 69 allocdim = dim + nentries;
70 data = cast(void**)GC.realloc(data, allocdim * (*data).sizeof); 70
71 auto newData = cast(void**)GC.malloc(allocdim * (*data).sizeof);
72 memcpy(newData, data, dim * (*data).sizeof);
73 // GC.free(data);
74 data = newData;
75
76 //data = cast(void**)GC.realloc(data, allocdim * (*data).sizeof);
71 } 77 }
72 } 78 }
73 79
74 final void setDim(uint newdim) 80 final void setDim(uint newdim)
75 { 81 {