home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / amiga / programm / 17346 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  1.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!natinst.com!news.dell.com!swrinde!emory!europa.asd.contel.com!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!uknet!edcastle!dcs.ed.ac.uk!jaxh
  2. From: jaxh@dcs.ed.ac.uk (Jon Hanson)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: fread() in C
  5. Message-ID: <Bz9F0u.FEx@dcs.ed.ac.uk>
  6. Date: 14 Dec 92 17:24:29 GMT
  7. References: <BysKr2.3vu@dcs.ed.ac.uk> <Ixw6s*Su2@spirits.ka.sub.org>
  8. Sender: cnews@dcs.ed.ac.uk (UseNet News Admin)
  9. Organization: Department of Computer Science, University of Edinburgh
  10. Lines: 31
  11.  
  12. In article <Ixw6s*Su2@spirits.ka.sub.org>, rob@spirits.ka.sub.org (Roland Bless) writes:
  13. > In article <BysKr2.3vu@dcs.ed.ac.uk>, Jon Hanson writes:
  14. > > I'm using fread() to read a large portion of a file into memory, using something like,
  15. > >
  16. > >       buffer = (struct [...] *) AllocMem(bufflen,MEMF_PUBLIC|...);
  17. > >       if (buffer) fread(&buffer,1,bufflen,fileptr);
  18. > > where bufflen is the portion lenght in bytes.
  19. > You should better use fread(&buffer,bufflen,1,fileptr); which means
  20. > to read bufflen bytes in 1 block instead of reading bufflen*1-byte blocks.
  21. > With ANSI-C <bufflen> is type size_t which is library dependent. This could
  22. > be "int" or "long int". If you link with 16-bit int's, so size_t is 16-bit,
  23. > you might run into problems with buffer sizes >64kB.
  24. > > crashes. Is there some problem with using fread() with large'ish read lengths ?
  25. > You should be aware what size the number arguments have.
  26. > Regards,
  27. >  Roland
  28.  
  29. To all the people who said that i should have put fread(buffer,..) not &buffer, this
  30. was actually a typo - I was using 'buffer`. The above seems like a possible solution.
  31.  
  32. Thanks for the help anyway.
  33.  
  34.    .
  35.    |on Hanson
  36.  `-' jaxh@dcs.ed.ac.uk
  37.