ARM Technical Support Knowledge Articles

USING XHUGE POINTERS WITH LIBRARY ROUTINES LIKE STRCPY

Applies to: C166 C Compiler

Answer


Information in this article applies to:


SYMPTOMS

I have a lot of data structures that are larger than 64K. They are declared with the xhuge memory type. I'm using strcpy to copy data and the copy doesn't seem to work correctly. I'm using the HLARGE memory model. Are there any known problems with doing this?

CAUSE

The problem you are having is a result of the assumed data type in the HLARGE memory mode. In HLARGE, variables are huge by default. The strcpy library routine (as well as many others) use standard types, for example:

char *strcpy (char *d, char *s);

The pointers you pass to strcpy are assumed to be pointers to huge variables and not pointers to xhuge variables.

RESOLUTION 1

A number of library routines have xhuge equivalents. For example:

For those functions that do not have xhuge equivalents, you must write your own. The following example shows how to write the strcpy library routine for xhuge variables.

char xhuge *xstrcpy (
  char xhuge *d,
  char xhuge *s)
{
char xhuge *r;

for (r = d; (*d = *s) != '\0'; s++, d++);

return (r);
}

RESOLUTION 2

A new memory model called XLarge has been introduced which uses xhuge pointer by default. The appropriate library functions will then be used automatically. This can be used since the C166 version 7.04.

MORE INFORMATION

Article last edited on: 2011-11-07 02:14:30

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential