Solved

NULL pointer assignment mark 2

Posted on 2000-04-18
6
268 Views
Last Modified: 2010-04-15
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
Comment
Question by:mogden
  • 3
  • 2
6 Comments
 

Author Comment

by:mogden
ID: 2729254
Thank you to those as answered.  This is agreat site.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2730104
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
 
LVL 30

Accepted Solution

by:
SteveGTR earned 200 total points
ID: 2738798
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:mogden
ID: 2741051
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
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2741614
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
 

Author Comment

by:mogden
ID: 2742639
Thanks heaps again, Steve.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now