TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: ANTHONY TIBBS
date: 1997-07-04 15:26:00
subject: Help! [1/2]

 >>> Part 1 of 2...
Okay, people, I've tried once, and received only one response.
Here we go again.
Recently, while working on an application, I have come across
a bug in the Squish Developer's Kit (v2.00) that has more or
less STOPPED my forward movement on the project.
The problem is this:  When accessing a *.MSG message base,
it is impossible to read the message text/control information
without causing a GPF or hanging the system, depending on the
operating system in use.  This bug has been tracked down
to the line of code
(void)memmove (newtext, text, (size_t)(bytes-(dword)(newtext-text)));
This is located on line ~643 in Src\API_SDM.C.
The suggestion was made to "manually" move the data instead of
using the compiler's function, so I wrote this small routine
(very quickly, mind you):
extern "C"           /* The rest of the app is in C++ */
{
void vmove (char *dest, char *src, size_t count)
{
unsigned char *s, *d;
size_t t=0L;
   d = dest;
   s = src;
   while (t < count)
   {
      *d = *s;
      d++;
      s++;
      t++;
   }
}
}
This also crashes, depending on whether I run it out of the
Borland IDE or from the command line.
The code that actually calls MsgReadMsg follows;
int LoadMessage (void)
{
dword tmp;                                /* Scratch variable */
char *buf;                                /* Message buffer.. was used
                                             for debugging purposes
                                             earlier */
   MAPI_CloseMessage();                   /* Close a message (if one is
                                             already open) */
   LogFile.Entry (">Allocating msgtext buffer");
   MsgInfo.MsgText = (char *)malloc (30001); /* Message buffer */
   if (MsgInfo.MsgText == NULL)
      return MAPI_No_Mem;                    /* #defined in header file */
   /* ... more debugging code ... */
   LogFile.Entry (">MsgText buffer allocated @ %p",MsgInfo.MsgText);
   LogFile.Entry (">MsgControlInfo allocating buffer");
   MsgInfo.ControlInfo = (char *)malloc (4096); /* Msg control data */
   if (MsgInfo.ControlInfo == NULL)
   {
      MAPI_CloseMessage();                      /* Deallocates mem */
      return MAPI_No_Mem;
   }
   LogFile.Entry (">MsgControlInfo buffer allocated @ %p...
   ... ",MsgInfo.ControlInfo);
   LogFile.Entry (">Reading message");
   /* This is where it hangs. */
   tmp = MsgReadMsg (MsgInfo.MsgH, &MsgInfo.Header, 0, 15000, ...
   ... MsgInfo.MsgText, 4096L, MsgInfo.ControlInfo);
   if (tmp == -1L)
   {
      if (tmp == MERR_NOMEM)
      {
         MAPI_CloseMessage();
         return MAPI_No_Mem;
      }
      return MAPI_Error;
   }
   free (buf);
   LogFile.Entry (">Returning");
   return MAPI_Loaded;                       /* "OK" */
 >>> Continued to next message...
___ Blue Wave/DOS v2.30 [NR]
--- Maximus 3.01
---------------
* Origin: World of Power BBS þ Private þ Ottawa, ON (1:163/215.38)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.