Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.os2.programmer.misc > #285

Re: Passing string pointers in a custom control-data structure == FAIL

From "Alex Taylor" <mail.me@reply.to.address>
Newsgroups comp.os.os2.programmer.misc
Subject Re: Passing string pointers in a custom control-data structure == FAIL
Date 2011-06-18 06:10 -0500
Organization Newscene Usenet News Service, http://www.newscene.com/
Message-ID <mdq090pMZSKk-pn2-dSLeGgdTNDug@localhost> (permalink)
References <mdq090pMZSKk-pn2-EHH7HPrgtTe2@localhost>

Show all headers | View raw


On Sat, 18 Jun 2011 04:08:01 UTC, "Alex Taylor" <mail.me@reply.to.address> 
wrote:

> Setting up the data structure is fine.  The problem is that, when it
> gets passed to the control, for some reason all the string pointers 
> are mangled (but the static fields are fine).  I've traced this as
> much as I can in the IBM debugger (IPMD).  In the calling function,
> the strings are fine.  As soon as WM_CREATE in the control's window
> procedure receives the structure, the strings are reported as invalid
> (presumably pointing off into never-never land).
> 
> Right now I'm using strdup() to allocate the strings in the structure,
> but I've also tried using DosAllocMem() plus strcpy(), which makes no 
> difference.

One think I forgot to mention... this doesn't always happen.  The
problem disappears and reappears as I make completely unrelated 
changes elsewhere in the program.  So I'll think it's fixed for a
while, then BANG it'll strike again.

At the moment it seems to be happening pretty consistently, though.

BTW, I've also tried allocating the entire infodata structure 
dynamically instead of declaring it statically... just in case
PM was happier with that.  It made zero difference.


> /**********************************************************
>  * In the VI class's window procedure:
>  */
> 
>   PVIPRIVATE pPrivate;    // pointer to private control data
>   PVICTLDATA pPublic;     // pointer to public control data
> 
>   // ...
>   case WM_CREATE:
>       if ( !mp1 ) return (MRESULT) TRUE;
>       pPublic = (PVICTLDATA) mp1;

Actually, I should say: at THIS point, pPublic->pszFS and 
pPublic->pszSize are already saying "invalid string".  Clearly
the correct pointers are never reaching the window procedure.


>       // initialize the private control data structure
>       pPrivate = (PVIPRIVATE) calloc( 1, sizeof( VIPRIVATE ));
>       if ( !pPrivate ) return (MRESULT) TRUE;
> 
>       pPrivate->ctldata.cb      = pPublic->cb;
>       pPrivate->ctldata.pszFS   = strdup( pPublic->pszFS );
>       pPrivate->ctldata.pszSize = strdup( pPublic->pszSize );
>       pPrivate->id          = ((PCREATESTRUCT)mp2)->id;
>       // ...
>       WinSetWindowPtr( hwnd, 0, pPrivate );
>       return (MRESULT) FALSE;


-- 
Alex Taylor
Fukushima, Japan
http://www.socis.ca/~ataylo00

Please take off hat when replying.

Back to comp.os.os2.programmer.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Passing string pointers in a custom control-data structure == FAIL "Alex Taylor" <mail.me@reply.to.address> - 2011-06-17 23:08 -0500
  Re: Passing string pointers in a custom control-data structure == FAIL Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-06-18 09:23 +0200
    Re: Passing string pointers in a custom control-data structure == FAIL "Alex Taylor" <mail.me@reply.to.address> - 2011-06-18 06:05 -0500
  Re: Passing string pointers in a custom control-data structure == FAIL "A.D. Fundum" <what.ever@neverm.ind> - 2011-06-18 12:14 +0200
    Re: Passing string pointers in a custom control-data structure == FAIL "Alex Taylor" <mail.me@reply.to.address> - 2011-06-18 06:03 -0500
  Re: Passing string pointers in a custom control-data structure == FAIL "Alex Taylor" <mail.me@reply.to.address> - 2011-06-18 06:10 -0500
    Re: Passing string pointers in a custom control-data structure == FAIL Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-06-20 09:55 +0200
      Re: Passing string pointers in a custom control-data structure == FAIL "Alex Taylor" <mail.me@reply.to.address> - 2011-06-20 09:01 -0500
        Re: Passing string pointers in a custom control-data structure == FAIL "Steven Levine" <steve53@nomail.earthlink.net> - 2011-06-20 10:50 -0500
          Re: Passing string pointers in a custom control-data structure == FAIL Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-06-21 08:23 +0200
          Re: Passing string pointers in a custom control-data structure == FAIL "Alex Taylor" <mail.me@reply.to.address> - 2011-06-21 06:50 -0500
            Re: Passing string pointers in a custom control-data structure == FAIL "Steven Levine" <steve53@nomail.earthlink.net> - 2011-06-24 23:17 -0500
              Re: Passing string pointers in a custom control-data structure == FAIL "Alex Taylor" <mail.me@reply.to.address> - 2011-06-26 06:50 -0500
          The actual program "Alex Taylor" <mail.me@reply.to.address> - 2011-06-21 06:59 -0500
            Re: The actual program "Steven Levine" <steve53@nomail.earthlink.net> - 2011-06-24 14:42 -0500
              Re: The actual program "Alex Taylor" <mail.me@reply.to.address> - 2011-06-26 06:48 -0500
        Re: Passing string pointers in a custom control-data structure == FAIL Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-06-21 08:39 +0200
    Re: Passing string pointers in a custom control-data structure == FAIL Paul Ratcliffe <abuse@orac12.clara34.co56.uk78> - 2011-06-20 09:30 +0000
  Re: Passing string pointers in a custom control-data structure == FAIL Peter Flass <Peter_Flass@Yahoo.com> - 2011-06-18 08:08 -0400
  Re: Passing string pointers in a custom control-data structure == FAIL Paul Ratcliffe <abuse@orac12.clara34.co56.uk78> - 2011-06-18 18:07 +0000
    Re: Passing string pointers in a custom control-data structure == FAIL "Alex Taylor" <mail.me@reply.to.address> - 2011-06-20 09:01 -0500
      Re: Passing string pointers in a custom control-data structure == FAIL "Lars Erdmann" <lars.erdmann@arcor.de> - 2011-06-22 22:22 +0200
      Re: Passing string pointers in a custom control-data structure == FAIL Marty <net@comcast.martyamodeo> - 2011-06-24 10:45 -0700
        Re: Passing string pointers in a custom control-data structure == FAIL "Rich Walsh" <spamyourself@127.0.0.1> - 2011-06-25 03:04 +0000
          Re: Passing string pointers in a custom control-data structure == FAIL "Steven Levine" <steve53@nomail.earthlink.net> - 2011-06-24 22:43 -0500
            Re: Passing string pointers in a custom control-data structure == FAIL "Rich Walsh" <spamyourself@127.0.0.1> - 2011-06-26 07:11 +0000
  Re: Passing string pointers in a custom control-data structure == FAIL James Moe <jimoeDESPAM@sohnen-moe.com> - 2011-06-18 21:43 -0700

csiph-web