| |||||
Technical Support Support Resources
Product Information | C166: USING XHUGE POINTERS WITH LIBRARY ROUTINES LIKE STRCPYInformation in this article applies to:
SYMPTOMSI 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? CAUSEThe 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. RESOLUTIONA 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);
}
MORE INFORMATION
Last Reviewed: Friday, July 15, 2005 | ||||