🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #1029

Problem in StringBrowser

#1029
From: Jan Chang
Date: Tue, 30 Apr 1991 16:32
44 lines
1842 bytes
   Environment: 
     IV2.6 on HP800 running C++ 2.1 
  OR IV2.6 on HP300 running C++ 2.0 

   Several of us in my division had the similar problem as follows:
using a multiple selections stringbrowser, we need to remove 
all the selected strings from one stringbrowser and insert them into 
another stringbrowser (or the same one) one by one.  The problem is 
from time to time we are getting garbage in the destination 
stringbrowser.  We suspect that it might be  memory corruption 
somewhere and have tried different ways to store the string returned 
from String(), but doesn't help.  Could anyone tell me what is the  
problem?

Thanks,
Jan

//Code to do the Removing and Inserting in a loop
// In this case, we are using only one stringbrowser.
void TestStsBrowser::ChangeStatus(char* newStsValue) 
{
   char *str;
   int index ;
   char *tmpstr;

   // Get number of strings being selected
   int count = _sts_sbr->Selections();

   for (int i = 0; i < count; ++i) 
   {
      index = _sts_sbr->Selection();
      str = _sts_sbr->String(index);

      tmpstr = new char[strlen((char*)str) + 1];
      strcpy (tmpstr, (char*)str);
      // Remove string from the browser
      _sts_sbr->Remove(index);
      
      // Insert string to the same index
      _sts_sbr->Insert((const char*)tmpstr, index);

   }
}
Technical Details
Message-ID: <9104301633.AA03559@hplds3.sid.hp.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!snorkelwacker.mit.edu!stanford.edu!HPLDS3.SID.HP.COM!janc

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!snorkelwacker.mit.edu!stanford.edu!HPLDS3.SID.HP.COM!janc
From: janc@HPLDS3.SID.HP.COM (Jan Chang)
Newsgroups: comp.windows.interviews
Subject: Problem in StringBrowser
Message-ID: <9104301633.AA03559@hplds3.sid.hp.com>
Date: 30 Apr 91 16:32:59 GMT
Sender: news@shelby.stanford.edu (USENET News System)
Organization: Internet-USENET Gateway at Stanford University
Lines: 44