Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
too much global data defined in file
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
adric22  
View profile  
 More options Sep 12, 1:29 pm
Newsgroups: comp.os.msdos.programmer
From: adric22 <adri...@yahoo.com>
Date: Sat, 12 Sep 2009 10:29:12 -0700 (PDT)
Local: Sat, Sep 12 2009 1:29 pm
Subject: too much global data defined in file
How do I allocate an array that is about 64K in size using turbo-C?
It gives me the error "too much global data defined in file."

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
p...@nospam.demon.co.uk  
View profile  
 More options Sep 13, 1:54 am
Newsgroups: comp.os.msdos.programmer
From: p...@nospam.demon.co.uk
Date: Sun, 13 Sep 2009 05:54:31 +0000 (UTC)
Local: Sun, Sep 13 2009 1:54 am
Subject: Re: too much global data defined in file
In article  <eaa8f518-f794-4dea-bcfa-5edff4c74...@y21g2000yqn.googlegroups.com>
           adri...@yahoo.com "adric22" writes:

> How do I allocate an array that is about 64K in size using turbo-C?
> It gives me the error "too much global data defined in file."

I'm not familiar with Turbo-C, but you could try specifying Large
or Huge model.  Or maybe Compact model if it's supported and
appropriate for your code.

Pete
--
   "We have not inherited the earth from our ancestors,
    we have borrowed it from our descendants."


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Russell  
View profile  
 More options Sep 13, 2:52 am
Newsgroups: comp.os.msdos.programmer
From: Alex Russell <alexander.russ...@telus.net>
Date: Sun, 13 Sep 2009 06:52:15 GMT
Local: Sun, Sep 13 2009 2:52 am
Subject: Re: too much global data defined in file
p...@nospam.demon.co.uk wrote:
> In article  <eaa8f518-f794-4dea-bcfa-5edff4c74...@y21g2000yqn.googlegroups.com>
>            adri...@yahoo.com "adric22" writes:

>> How do I allocate an array that is about 64K in size using turbo-C?
>> It gives me the error "too much global data defined in file."

> I'm not familiar with Turbo-C, but you could try specifying Large
> or Huge model.  Or maybe Compact model if it's supported and
> appropriate for your code.

> Pete

large model - far data and code
medium - near data, far code
compact - far data, near code
small - near data, near code
tiny - data and code in same segment

char *t1;
char *at1;

t1=malloc(number_of_bytes);

/* use t1 */
*t1='a';
for ( i=0; i < number_of_bytes; i++ )
        t1[i]=0;
at1=t1;
for ( i=0; i < number_of_bytes; i++ )
        *at1++=0;

free(t1);
t1=NULL;

Alex


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
adric22  
View profile  
 More options Sep 13, 2:57 pm
Newsgroups: comp.os.msdos.programmer
From: adric22 <adri...@yahoo.com>
Date: Sun, 13 Sep 2009 11:57:20 -0700 (PDT)
Local: Sun, Sep 13 2009 2:57 pm
Subject: Re: too much global data defined in file

> char *t1;
> char *at1;

> t1=malloc(number_of_bytes);

> /* use t1 */
> *t1='a';
> for ( i=0; i < number_of_bytes; i++ )
>         t1[i]=0;
> at1=t1;
> for ( i=0; i < number_of_bytes; i++ )
>         *at1++=0;

> free(t1);
> t1=NULL;

Thanks for the help... but I'm not getting how to use this.  Where do
I specify these large, medium, compact, etc?

Also, I tried using the malloc() but I'm not sure where to put that.
Does it go in the global variable space, or in an actual procedure as
part of the code?  I tried it both ways and got an error.  I tried
this:

unsigned char *variablespace;
variablespace=malloc(65535);

but it complained and gave two errors:
1) declaration needs type or storage class.
2) type mismatch in redeclaration of 'viarablespace'

Essentially I'm trying to create a large array called variablespace
that is at least 64K in size.  I looked at that code snippet there,
but I am not entirely sure what you are showing me.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Russell  
View profile  
 More options Sep 13, 6:39 pm
Newsgroups: comp.os.msdos.programmer
From: Alex Russell <alexander.russ...@telus.net>
Date: Sun, 13 Sep 2009 22:39:47 GMT
Local: Sun, Sep 13 2009 6:39 pm
Subject: Re: too much global data defined in file

If you are using the IDE the "memory model" will be one of the global
compilation options. The memory model controls what kind of default
pointer (far or near) is used for code and data.

large is often a good choice is there is a lot of code and data.

malloc is used right in the c code, often right in the function where
the memory is used. malloc returns a chunk of memory that can be used by
your program. malloc returns a POINTER to the memory.

here is an example of using an array, statically declared and
dynamically declared.

#define STR_LEN 127
#define NUM_FOOS 100

typedef struct
{
int x,y,z;
char str[STR_LEN+1];

}

foo_t;

/* static */

foo_t lots_of_foo[NUM_FOOS];
int i;

for ( i=0; i < NUM_FOOS; i++ )
        {
        lots_of_foo[i].x=100;
        lots_of_foo[i].y=1;
        lots_of_foo[i].z=22;
        strcpy(lots_of_foo[i].str, "a string");
        }

/* dynamic */

foo_t foo_pointer, *ft;
int i;

        foo_pointer=malloc(sizeof(foo_t * NUM_FOOS);
        /* malloc allocates bytes */
        /* foo_pointer points toa region of memory big enough to hold 100 foo_
structures */

        /* access foo_pointer using pointer syntax */
        for ( ft=foo_pointer, i=0; i < NUM_FOOS; i++, ft++ )
                {
                ft->x=123;
                ft->y=22;
                ft->z=77;
                strcpy(ft->str, "a string");
                }

        /* and showing how pointers can be treated like arrays */
        for ( i=0; i < NUM_FOOS; i++ )
                {
                foo_pointer[i].x=45;
                foo_pointer[i].y=22;
                strcpy(foo_pointer[i], "a string");
                }

        free(foo_pointer);  /* once all done with the memory, free it so it can
be used again for something else */

ft++
c knows ft points to a foo_t so the ++ operator adds the siz eof foo_t
to the pointer, and it now to the next structure.

Alex


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google