home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18320 < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.5 KB  |  60 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!uunet.ca!ohrd!nkripoto
  3. From: nkripoto@rd.hydro.on.ca (Nick Kripotos (T))
  4. Subject: Is this a Bug in Borland C++ 2.0
  5. Message-ID: <1992Dec22.200126.24911@rd.hydro.on.ca>
  6. Organization: Ontario Hydro - Research Division
  7. Date: Tue, 22 Dec 92 20:01:26 GMT
  8. Lines: 50
  9.  
  10. Hello there everyone.  I have a small problem which is more of a nuisance
  11. and would like to fix it.
  12.  
  13. I have a piece of code which compiles and links no problem.  However sometimes
  14. when I try to run the executable the computer will crash or I get a message
  15. like the following:
  16.  
  17.     Abnormal program termination
  18.     Floating point error: Domain
  19.  
  20. Sometimes all I do is add a simple printf statement and the program crashes
  21. when I try to execute it.  This usually happens after a few normal compilations
  22. and then a crash will occur
  23.  
  24. I think it must be the way I'm allocating memory but I can't tell.
  25.  
  26. Here is a chuck of my code:
  27.  
  28. #define MAX_READ_BYTES 65532
  29. #define unsigned int SIGPT
  30.  
  31. ulong MaxBufPts;
  32. SIGPT *DBuffer;
  33.  
  34. etc.
  35.  
  36. if ((MaxBufPts=farcoreleft()/sizeof(SIGPT)))>MAX_READ_BYTES/sizeof(SIGPT))
  37.   {
  38.    MaxBufPts=MAX_READ_BYTES/sizeof(SIGPT);
  39.   }
  40. if ((DBuffer=(SIGPT *)farmalloc(MaxBufPts*sizeof(SIGPT)))==NULL)
  41.   { 
  42.   printf("Not enough memory");
  43.   }
  44.  
  45. etc.
  46.  
  47. farfree(DBuffer);
  48.  
  49. end
  50.  
  51. At first I didn't have the farfree(DBuffer) line but then I added it and
  52. I still get the occasional crash.
  53.  
  54. If anyone has any ideas or suggestions please post or e-mail me at
  55.  
  56. kripotos@ice5.kcps.rd.hydro.on.ca
  57.  
  58. Thanks
  59. Nick
  60.