• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

NULL pointer assignment mark 2

Original question...

#define FONTSIZE 256*8
                     unsigned char _far *UserFont;
                     unsigned char _far *OurFont;
                     void LoadFont(void);
                     void NewFont(unsigned char _far *font);
                     void OldFont(void);

                     void LoadFont(void)
                     {
                     FILE *fontfile;
                     if((OurFont = (char *)malloc(FONTSIZE)) == NULL)
                     {
                     puts("Not enough memory");
                     exit(1);
                     }
                     if((fontfile = fopen("pudgey.fnt", "rb")) == NULL)
                     {
                     puts("Can't open file");
                     exit(1);
                     }
                     fread(OurFont, FONTSIZE, 1, fontfile);
                     fclose(fontfile);
                     }

                     void NewFont(unsigned char _far *font)
                     {
                     UserFont = (char _far *)0x0000010E;
                     FP_SEG(font) = 0x010E;
                     FP_OFF(font) = 0x010C;
                     }

                     void OldFont(void)
                     {
                     FP_SEG(UserFont) = 0x010E;
                     FP_OFF(UserFont) = 0x010C;
                     }
Thanks to all the guys who responded to my previous question.  I'm sorry, I couldn't give points to all.  Click on the 1st that looked good.  Didn't seem to be an option to give to others.  Have made enquiries, though.

The R6001 error message is:
      run-time error R6001 - null pointer assignment
It seems to mean, the contents of my NULL segment are changing during my program's execution.

Tried:
((OurFont = (unsigned char _far *)malloc(FONTSIZE)) == NULL)
No Change.  But for once QC25 didn't give me any grief.  Can work with this.

FP_SEG(UserFont) = 0x010E;
FP_OFF(UserFont) = 0x010C;
UserFont = NULL
 and
UserFont = MK_FP(0x10E, 0x10C);
Courtesy of Alex.  Want him to have 200 points too!
No Change.  And still QC25 didn't complain.  Another 1 to work with.

Okay Guys, I'm trying to write a stand-alone program called I-Ching.  It's a Chinese philosophy.  Pulled down a few interesting fonts from the net.  Seem really to suit it.  Different formats? yeah.  Wouldn't mind being able to use some of the .TTF files.  I use QuickC 25.  Old, but, as I said, I like it.  It shows you what to write for different platforms.  One of Microsoft's better efforts!
0
mogden
Asked:
mogden
  • 3
  • 2
1 Solution
 
mogdenAuthor Commented:
Thank you to those as answered.  This is agreat site.
0
 
AlexVirochovskyCommented:
modgen, i don't understand:
>>UserFont = MK_FP(0x10E, 0x10C);
works or not?
And how you use value of UserFont?
>>Courtesy of Alex.  
>>Want him to have 200 points too!
 If code works, i can reply to you Q.



0
 
SteveGTRCommented:
Sounds like a memory corruption problem to me. I've seen MS 6.0 issue this at program termination when you do fclose() twice on the same FILE*:

fclose(fontfile);
fclose(fontfile);

When does the problem occur? Can you trace it to an individual statement? Your LoadFont() routine looks okay. NewFont() and OldFont() should definately use MK_FP(), but why you'd want a pointer to 010E::010C eludes me...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mogdenAuthor Commented:
For SteveGTR:
(fontfile = fopen("pudgey.fnt", "rb")) == NULL;
---It says it can't open the file.

Help me quick, please.  I'm running out of points.

Cheers.

Colin:)
0
 
AlexVirochovskyCommented:
That means, that file pudgey.fnt not
found in you directory.
May be this one has other name
May be is placed in other directory(not
in yous). In this case you must
set full path as
fontfile = fopen("C:\\mydir\\pudgey.fnt", "rb");
0
 
mogdenAuthor Commented:
Thanks heaps again, Steve.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now