Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!oliveb!amdahl!netcom!boba From: boba@netcom.COM (Bob Amstadt) Newsgroups: comp.os.msdos.misc Subject: Re: !@#$ 64k segments! Message-ID: <1991Apr9.185939.9175@netcom.COM> Date: 9 Apr 91 18:59:39 GMT References: <14049@ccncsu.ColoState.EDU> Organization: Netcom - Online Communication Services UNIX System {408 241-9760 guest} Lines: 23 In article <14049@ccncsu.ColoState.EDU> millerje@mozart.cs.colostate.edu (Jeff Miller) writes: >I am writing a program in C, and just to make life easy, I want to malloc >(actually calloc) a data space > 64k. I noticed that if I malloc <65535 >bytes (<64k) I can fread directly into that buffer. What I'd like to do >is be able to fread into a buffer about 256k in size. (The reason for this >is speed). I have tried the large memory model as well as huge pointers, but >to no avail. Are there any special versions of malloc &/or calloc that >will let me do this? Actually you have another problem. Once you allocate the buffer, fread is incapable of reading more than 64k at a time. You have to go through DOS with fread, and it does not allow reads larger than 64k. However, this is not a major problem. I once did some tests, and found that reads in blocks of 16k or better all had similar performance. 64k offers almost no advantage over 32k, and the difference between 32k and 16k is also minimal. If you have the memory, 32k is probably the best size to use. It is the largest convenient size to use because the blocksize still fits in a 16-bit unsigned int. -- Bob Amstadt boba@netcom.com 408-738-2479