www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/07/12/00:16:13

From: "raelenekelly1" <raelenekelly1 AT bigpond DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Alocating Memory to a Referenced Pointer!
Lines: 49
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <k7rX8.33294$Hj3.100060@newsfeeds.bigpond.com>
Date: Fri, 12 Jul 2002 12:34:29 +1000
NNTP-Posting-Host: 144.134.239.6
X-Trace: newsfeeds.bigpond.com 1026440784 144.134.239.6 (Fri, 12 Jul 2002 12:26:24 EST)
NNTP-Posting-Date: Fri, 12 Jul 2002 12:26:24 EST
Organization: Telstra BigPond Internet Services (http://www.bigpond.com)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi all..

Myself and a few other posts on this newsgroup in the past have
had trouble allocating memory to a pointer passed by reference.

reference:
    ->'graphics programming: need help with debugging; 8/7/02 post
    ->and my 3d engine
both become unstable if you use external functions to allocate memory!

e.g.

int F_Allocate_Mem(char *v_string)
{
    v_string=(char *) malloc (200 *sizeof(char));
};

void main ()
{
    char * BigStringVariable;
    int response;
    response=F_Allocate_Mem(&BigStringVariable);
    exit(0);
};

This is the kind of setup im talking about!

It seems to me that although v_string and
BigStringVariable both point to the same
memory location at the start of the
F_Allocate_Mem function, only the memory
location of v_string would be reassigned by malloc.

If this is so, then how can i assign memory to a pointer
using an external function?

at the moment i steer round the problem by using class's
but even that can become unstable at times!

by ustable i mean - Sometimes the function works and i can
use the allocated memory. Other Times you can't.

Any Thoughts /  Suggestions would be much appreciated !

....MickyDe




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019