June 21, 2001 hcalloc | ||||
---|---|---|---|---|
| ||||
You might consider adding this function to the runtimes. In 16-bit runtimes, huge pointers may be allocated and freed. What is lacking is an equivalent of calloc which clears the memory when it is allocated. Here's my version. void __huge *_hcalloc(long num, size_t size) { char __huge *data; unsigned long int actual_bytes,i; data = _halloc(num,size); if (data != NULL) { actual_bytes = num * size; for(i=0;i<actual_bytes;i++) *data++ = 0; } return data; } Mark |
June 21, 2001 Re: hcalloc | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mark Evans | Sorry, make that: // Digital Mars runtime lacks a calloc-style function for huge pointers void __huge *_hcalloc(long num, size_t size) { void __huge *data; char __huge *clearptr; unsigned long int actual_bytes,i; data = _halloc(num,size); if (data != NULL) { clearptr = data; actual_bytes = num * size; for(i=0;i<actual_bytes;i++) *clearptr++ = 0; } return data; } |
Copyright © 1999-2021 by the D Language Foundation