Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-ID: <000b01bee26b$b77db700$8101010a@gblues> From: "Nathan Strong" To: References: <000501bee1fd$f645d620$5001010a AT gblues> <9185 DOT 990809 AT mindspring DOT com> Subject: Re: B20: large fread() calls fail Date: Mon, 9 Aug 1999 06:33:07 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 > Hello Nathan, > > Chances are it is the difference between text and binary mode: > The EOL character gets expanded into CRLF when you read, so more > characters are read than the stat() is telling you. It sometimes works > because of the way memory is allocated and whether or not you > overwrite something important when you overflow the buffer. Hmm.. a good possibility, but I don't think it's correct. What I did was use an #ifdef on the fopen() that looked like this: #ifdef CYGNUS /* CYGNUS is defined with a -DCYGNUS at compile time */ if( (fp = fopen(filename, "rb")) == NULL ) /* use binary mode w/ cygwin */ #else if( (fp = fopen(filename, "r")) == NULL ) #endif > Also I would note that you have a couple of places you can > lose a bunch of memory - those places you return after allocating > memory but are unable to fill it. Good eye, I've cought those. Those weren't the problem either :\ Here are the file sizes for the files that aren't loading: -rw-r--r-- 1 500 everyone 142004 Jul 30 20:12 help.remorts.new -rw-r--r-- 1 500 everyone 41358 Aug 6 01:16 help.mortskills.new -rw-r--r-- 1 500 everyone 85336 Jul 4 23:03 woodland.are -rw-r--r-- 1 500 everyone 7206 Jul 26 13:22 Lancelot.are What's odd is that there are larger files than these that seem to have no problems loading, such as the following file: -rw-r--r-- 1 500 everyone 320797 Jun 26 17:10 shay.are As you can see, it's larger than the above areas combined. Nathan Strong gblues AT jps DOT net -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com