Message-ID: <399987A3.141A6A49@ntlworld.com> From: Steven Watson X-Mailer: Mozilla 4.7 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: newbie makelong? References: <39985C49 DOT 3542BDAC AT ntlworld DOT com> <39986125 DOT 80837DE6 AT ntlworld DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 49 Date: Tue, 15 Aug 2000 19:10:43 +0100 NNTP-Posting-Host: 62.254.78.169 X-Complaints-To: abuse AT net DOT ntl DOT com X-Trace: news6-win.server.ntlworld.com 966363339 62.254.78.169 (Tue, 15 Aug 2000 19:15:39 BST) NNTP-Posting-Date: Tue, 15 Aug 2000 19:15:39 BST Organization: ntlworld News Service To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi Damian, Thanks for pointing out the non portability I dont have NT just win95 I will have to look for a portable way the code comes from a Tutorial on C circular 1994, there is little error trapping being done you are quite correct to trap for memory allocation errors I do for Windows programming C and Oberon-2,just trying to make sense of Dos. Steven Watson Damian Yerrick wrote: > > On Mon, 14 Aug 2000 22:14:13 +0100, Steven Watson > wrote: > > > #include > > #include > > > > void * MK_FP (unsigned short seg, unsigned short ofs) > > { > > if ( !(_crt0_startup_flags & _CRT0_FLAG_NEARPTR) ) > > if (!__djgpp_nearptr_enable ()) > > return (void *)0; > > On NT and in some other situations, this makes a null pointer. > > > return (void *) (seg*16 + ofs + __djgpp_conventional_base); > > } > > And you don't trap for the null pointer. > > >> ptr = MK_FP(0xB800,offset); > >> > >> while(*str) > >> { > >> *ptr++= *str++; > >> ptr++; > > On NT, your program will crash. > > -- > Damian Yerrick > "I refuse to listen to those who refuse to listen to reason." > See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html > > This is McAfee VirusScan. Add these two lines to your signature to > prevent the spread of signature viruses. http://www.mcafee.com/