TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Joe Ripley
from: Kurt Kuzba
date: 1999-01-21 01:29:22
subject: Null pointer assignment

JR>   Null pointer assignment
JR>   could someone please give me an example of storing a
JR>   value to an uninitialized pointer?  thanks!
   You compiler should actually issue a warning if you have
   them turned on, unless you are passing the uninitialized
   pointer to another function before using it. I know that
   Borland DOES warn of possible use of uninitialized
   variables.
   It works like this.
   You define a pointer
char *Mystring;
   Then you give is memory with which to work,
Mystring = malloc(80 * sizeof(char));
   or point it to existing memory
Mystring = Mydata->Customer.first_name;
   Borland, in their wisdom, decided to put a buffer at the
   beginning of their program segment, so that when you use
   a pointer which has not been assigned an address to which
   it should point, it puts data into that buffer area, which
   is used to hold their compiler version data and such.
   If that data is changed during program operation, you will
   get a NULL pointer assignment error on program exit.
   You will have to follow every pointer you use to be certain
   that it is pointing to something before using it.
   Also, turn on your warnings if you have not already done so.
   When you don't get any warnings, it should mean that all
   errors the compiler CAN identify have been eliminated.
   That doesn't mean you won't have logical errors, bounds
   errors, or other bugs, but at least you have most of the
   obvious errors tripping flags when you compile.

> ] It's never funny when you have to explain it. [ Joe Friday ]

---
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
SEEN-BY: 396/1 632/0 371 633/260 262 267 270 371 634/397 635/506 728 639/252
SEEN-BY: 670/218
@PATH: 154/750 222 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

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™.