Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

NULL pointer assignment mark 2

Posted on 2000-04-18
6
Medium Priority
?
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

609 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