🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.oodesign
Article #94

Re: Function call to pull chip info & save to file. Problem shows after 45 calls. (PROBLEM SOLVED!!!!)

#94
From: Ronald Boucher
Date: Mon, 30 Aug 2004 13:29
36 lines
2652 bytes
"Ronald Boucher" <ron.boucher@xerox.com> wrote:
>
>I have created a function which pull the data info from a chip and save & append to a single file, then returns a int value which indicate success/failure.
>
>When I click the button to call the read/dump function about 45 times, the file somehow cannot be opened.  I checked out the memory address of file object "fp" (from FILE* fp declaration).  After 45 times, the fp address turned out to be null... I wonder if that means the fp address has ran out of place to open an new address?  I had to restart the application to continue with the rest of the chips after 45 calls.  How do I reset the memory address or keep it the same?  The file name is generated,
>depending on validity of the chip, line number, date, and the program name.  Anyone help? 
>
>Sample Code: 
>(note: output variable is char[] array for chip info.)
>
>
>#include <fstream.h>
>
>int Dump::DumpCRUM(char mode) 
>// mode variable is used for either 'f'ilter or 'm'ain modules
>{
>  // FileName string is generated
>  
>  ofstream dumpfile(FileName.c_str(), ios::app);
>  if (!dumpfile)
>    {
>      return -1;
>    }
>  else
>    {
>      dumpfile << output;
>      dumpfile.close();
>    }
>  return 1;
>}
>
>I haven't created a constructor & destructor in this Dump class.  Perhaps this will help?
>

This code was written on the dump.cpp file. I have investigated from our original source code and spotted one thing I missed. I realized that when creating the filename string, it caused the stream buffer to overflow. So I had to add one line code (just after "dumpfile.close();") with "FileName = NULL;". This will help to free up the file stream buffer, and to prevent overflow. 
Technical Details
Message-ID: <41332bba@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed.mesh.ad.jp!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <412f677b$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,7e0fd51c39b67c62
X-Google-Attributes: gid10db1e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ronald Boucher" <ron.boucher@xerox.com>
Sender: "Ronald Boucher" <ron.boucher@xerox.com>
Reply-To: "Ronald Boucher" <ron.boucher@xerox.com>
Subject: Re: Function call to pull chip info & save to file. Problem shows after 45 calls. (PROBLEM SOLVED!!!!)
Newsgroups: borland.public.cppbuilder.oodesign
X-User-Info: 13.13.137.1     
References:  <412f677b$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <41332bba@newsgroups.borland.com>
Date: 30 Aug 2004 06:29:30 -0700
X-Trace: newsgroups.borland.com 1093872570 207.105.83.66 (30 Aug 2004 06:29:30 -0700)
Lines: 37
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed.mesh.ad.jp!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail