🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #202

C Programming : Need help please .

#202
From: CalvinKong
Date: Mon, 18 Jan 1999 00:00
46 lines
2568 bytes
I had find out the part that causing the problem . But I still don't know
why it occurs .. Logically , it should be okay . Here is a program that I
extracted out and modified , please discuss with me ...
************************************************************
# include <stdlib.h>
typedef struct ListType {
 int       item;
 struct ListType *link;
}Node;
typedef Node *List;

int main()
{
 List temp;

 temp = (List)malloc (sizeof(List));
 temp->link = NULL;
 free(temp);
 return (0);
}
************************************************************
I think the causing problem is the malloc statement . If I change the malloc
statement into this "temp = (List)malloc (sizeof(Node))" , then when come to
the "free(temp)" it will works as what I expect it to work . Anyone can
explain the side effect of using the List instead of Node ? The problem is ,
even if I use List , the program will still execute as I expect after I
choose Ignore in the Error Message Box that pop up during execution of the
"free(temp)" statement .

/*********ERROR Message box***********/
Debug Error!
Damage : after Normal block (#20) at 0X00780EC0
Press Retry to debug the application
Abort           Retry           Ignore
/*********************************************/

--
- Calvin Kong -
----------------------------------------------------------------------------
--------
Are you dare enough to enter my homepage ?
Homepage : http://members.xoom.com/calvin_kong/
Email          : ypkong@tm.net.my
ICQ             : 3715937
----------------------------------------------------------------------------
-------
Technical Details
Message-ID: <36a2cb23.0@news2.tm.net.my>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109edf,44c9aa94f48f7403,start
X-Google-Attributes: gid109edf,public
X-Google-Thread: f9d99,44c9aa94f48f7403,start
X-Google-Attributes: gidf9d99,public
X-Google-Thread: 1011f8,44c9aa94f48f7403,start
X-Google-Attributes: gid1011f8,public
X-Google-Thread: 114592,44c9aa94f48f7403,start
X-Google-Attributes: gid114592,public
X-Google-Thread: 10d4ba,44c9aa94f48f7403,start
X-Google-Attributes: gid10d4ba,public
From: "CalvinKong" <ypkong@tm.net.my>
Subject: C Programming : Need help please .
Date: 1999/01/18
Message-ID: <36a2cb23.0@news2.tm.net.my>
X-Deja-AN: 433887059
X-NNTP-Posting-Host: bat-46-124.tm.net.my
X-Trace: 18 Jan 1999 13:48:19 +0800, bat-46-124.tm.net.my
Organization: TMnet Malaysia
Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,jaring.pcbase,tmnet.communities,tmnet.support
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3