Mail Archives: djgpp/2000/08/15/14:30:11
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
> <steven DOT watson AT ntlworld DOT com> wrote:
>
> > #include <sys/nearptr.h>
> > #include <crt0.h>
> >
> > 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/
- Raw text -