Merge remote branch 'mattst88/master'

This commit is contained in:
Keith Packard 2010-09-10 11:50:27 -07:00
commit ca0d578d29
13 changed files with 22 additions and 64 deletions

View File

@ -1154,8 +1154,7 @@ void
AssignTypeAndName(DeviceIntPtr dev, Atom type, char *name) AssignTypeAndName(DeviceIntPtr dev, Atom type, char *name)
{ {
dev->xinput_type = type; dev->xinput_type = type;
dev->name = (char *)malloc(strlen(name) + 1); dev->name = strdup(name);
strcpy(dev->name, name);
} }
/*********************************************************************** /***********************************************************************

View File

@ -96,7 +96,7 @@ AddExtension(char *name, int NumEvents, int NumErrors,
free(ext); free(ext);
return NULL; return NULL;
} }
ext->name = malloc(strlen(name) + 1); ext->name = strdup(name);
ext->num_aliases = 0; ext->num_aliases = 0;
ext->aliases = (char **)NULL; ext->aliases = (char **)NULL;
if (!ext->name) if (!ext->name)
@ -105,7 +105,6 @@ AddExtension(char *name, int NumEvents, int NumErrors,
free(ext); free(ext);
return((ExtensionEntry *) NULL); return((ExtensionEntry *) NULL);
} }
strcpy(ext->name, name);
i = NumExtensions; i = NumExtensions;
newexts = (ExtensionEntry **) realloc(extensions, newexts = (ExtensionEntry **) realloc(extensions,
(i + 1) * sizeof(ExtensionEntry *)); (i + 1) * sizeof(ExtensionEntry *));
@ -164,10 +163,9 @@ Bool AddExtensionAlias(char *alias, ExtensionEntry *ext)
if (!aliases) if (!aliases)
return FALSE; return FALSE;
ext->aliases = aliases; ext->aliases = aliases;
name = malloc(strlen(alias) + 1); name = strdup(alias);
if (!name) if (!name)
return FALSE; return FALSE;
strcpy(name, alias);
ext->aliases[ext->num_aliases] = name; ext->aliases[ext->num_aliases] = name;
ext->num_aliases++; ext->num_aliases++;
return TRUE; return TRUE;

View File

@ -377,8 +377,7 @@ KdXVInitAdaptors(
pa->ddGetPortAttribute = KdXVGetPortAttribute; pa->ddGetPortAttribute = KdXVGetPortAttribute;
pa->ddQueryBestSize = KdXVQueryBestSize; pa->ddQueryBestSize = KdXVQueryBestSize;
pa->ddQueryImageAttributes = KdXVQueryImageAttributes; pa->ddQueryImageAttributes = KdXVQueryImageAttributes;
if((pa->name = malloc(strlen(adaptorPtr->name) + 1))) pa->name = strdup(adaptorPtr->name);
strcpy(pa->name, adaptorPtr->name);
if(adaptorPtr->nEncodings && if(adaptorPtr->nEncodings &&
(pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) { (pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
@ -388,8 +387,7 @@ KdXVInitAdaptors(
{ {
pe->id = encodingPtr->id; pe->id = encodingPtr->id;
pe->pScreen = pScreen; pe->pScreen = pScreen;
if((pe->name = malloc(strlen(encodingPtr->name) + 1))) pe->name = strdup(encodingPtr->name);
strcpy(pe->name, encodingPtr->name);
pe->width = encodingPtr->width; pe->width = encodingPtr->width;
pe->height = encodingPtr->height; pe->height = encodingPtr->height;
pe->rate.numerator = encodingPtr->rate.numerator; pe->rate.numerator = encodingPtr->rate.numerator;
@ -441,8 +439,7 @@ KdXVInitAdaptors(
pat->flags = attributePtr->flags; pat->flags = attributePtr->flags;
pat->min_value = attributePtr->min_value; pat->min_value = attributePtr->min_value;
pat->max_value = attributePtr->max_value; pat->max_value = attributePtr->max_value;
if((pat->name = malloc(strlen(attributePtr->name) + 1))) pat->name = strdup(attributePtr->name);
strcpy(pat->name, attributePtr->name);
} }
pa->nAttributes = adaptorPtr->nAttributes; pa->nAttributes = adaptorPtr->nAttributes;
pa->pAttributes = pAttribute; pa->pAttributes = pAttribute;

View File

@ -1267,7 +1267,7 @@ xf86MsgVerb(MessageType type, int verb, const char *format, ...)
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
xf86VDrvMsgVerb(-1, type, verb, format, ap); LogVMessageVerb(type, verb, format, ap);
va_end(ap); va_end(ap);
} }
@ -1278,7 +1278,7 @@ xf86Msg(MessageType type, const char *format, ...)
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
xf86VDrvMsgVerb(-1, type, 1, format, ap); LogVMessageVerb(type, 1, format, ap);
va_end(ap); va_end(ap);
} }

View File

@ -1046,11 +1046,6 @@ xf86PrintDefaultLibraryPath(void)
int int
ddxProcessArgument(int argc, char **argv, int i) ddxProcessArgument(int argc, char **argv, int i)
{ {
/*
* Note: can't use xalloc/xfree here because OsInit() hasn't been called
* yet. Use malloc/free instead.
*/
#define CHECK_FOR_REQUIRED_ARGUMENT() \ #define CHECK_FOR_REQUIRED_ARGUMENT() \
if (((i + 1) >= argc) || (!argv[i + 1])) { \ if (((i + 1) >= argc) || (!argv[i + 1])) { \
ErrorF("Required argument to %s not specified\n", argv[i]); \ ErrorF("Required argument to %s not specified\n", argv[i]); \
@ -1067,10 +1062,9 @@ ddxProcessArgument(int argc, char **argv, int i)
{ {
char *mp; char *mp;
CHECK_FOR_REQUIRED_ARGUMENT(); CHECK_FOR_REQUIRED_ARGUMENT();
mp = malloc(strlen(argv[i + 1]) + 1); mp = strdup(argv[i + 1]);
if (!mp) if (!mp)
FatalError("Can't allocate memory for ModulePath\n"); FatalError("Can't allocate memory for ModulePath\n");
strcpy(mp, argv[i + 1]);
xf86ModulePath = mp; xf86ModulePath = mp;
xf86ModPathFrom = X_CMDLINE; xf86ModPathFrom = X_CMDLINE;
return 2; return 2;
@ -1079,10 +1073,9 @@ ddxProcessArgument(int argc, char **argv, int i)
{ {
char *lf; char *lf;
CHECK_FOR_REQUIRED_ARGUMENT(); CHECK_FOR_REQUIRED_ARGUMENT();
lf = malloc(strlen(argv[i + 1]) + 1); lf = strdup(argv[i + 1]);
if (!lf) if (!lf)
FatalError("Can't allocate memory for LogFile\n"); FatalError("Can't allocate memory for LogFile\n");
strcpy(lf, argv[i + 1]);
xf86LogFile = lf; xf86LogFile = lf;
xf86LogFileFrom = X_CMDLINE; xf86LogFileFrom = X_CMDLINE;
return 2; return 2;

View File

@ -429,8 +429,7 @@ xf86XVInitAdaptors(
pa->ddGetPortAttribute = xf86XVGetPortAttribute; pa->ddGetPortAttribute = xf86XVGetPortAttribute;
pa->ddQueryBestSize = xf86XVQueryBestSize; pa->ddQueryBestSize = xf86XVQueryBestSize;
pa->ddQueryImageAttributes = xf86XVQueryImageAttributes; pa->ddQueryImageAttributes = xf86XVQueryImageAttributes;
if((pa->name = malloc(strlen(adaptorPtr->name) + 1))) pa->name = strdup(adaptorPtr->name);
strcpy(pa->name, adaptorPtr->name);
if(adaptorPtr->nEncodings && if(adaptorPtr->nEncodings &&
(pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) { (pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
@ -440,8 +439,7 @@ xf86XVInitAdaptors(
{ {
pe->id = encodingPtr->id; pe->id = encodingPtr->id;
pe->pScreen = pScreen; pe->pScreen = pScreen;
if((pe->name = malloc(strlen(encodingPtr->name) + 1))) pe->name = strdup(encodingPtr->name);
strcpy(pe->name, encodingPtr->name);
pe->width = encodingPtr->width; pe->width = encodingPtr->width;
pe->height = encodingPtr->height; pe->height = encodingPtr->height;
pe->rate.numerator = encodingPtr->rate.numerator; pe->rate.numerator = encodingPtr->rate.numerator;
@ -493,8 +491,7 @@ xf86XVInitAdaptors(
pat->flags = attributePtr->flags; pat->flags = attributePtr->flags;
pat->min_value = attributePtr->min_value; pat->min_value = attributePtr->min_value;
pat->max_value = attributePtr->max_value; pat->max_value = attributePtr->max_value;
if((pat->name = malloc(strlen(attributePtr->name) + 1))) pat->name = strdup(attributePtr->name);
strcpy(pat->name, attributePtr->name);
} }
pa->nAttributes = adaptorPtr->nAttributes; pa->nAttributes = adaptorPtr->nAttributes;
pa->pAttributes = pAttribute; pa->pAttributes = pAttribute;

View File

@ -212,10 +212,8 @@ LoaderOpen(const char *module, const char *cname, int handle,
refCount[new_handle] = 1; refCount[new_handle] = 1;
tmp = _LoaderListPush(); tmp = _LoaderListPush();
tmp->name = malloc(strlen(module) + 1); tmp->name = strdup(module);
strcpy(tmp->name, module); tmp->cname = strdup(cname);
tmp->cname = malloc(strlen(cname) + 1);
strcpy(tmp->cname, cname);
tmp->handle = new_handle; tmp->handle = new_handle;
tmp->module = moduleseq++; tmp->module = moduleseq++;

View File

@ -88,15 +88,9 @@ extern const ModuleVersions LoaderVersionInfo;
extern unsigned long LoaderOptions; extern unsigned long LoaderOptions;
/* Internal Functions */ /* Internal Functions */
void LoaderDuplicateSymbol(const char *, const int);
char *_LoaderModuleToName(int);
int LoaderOpen(const char *, const char *, int, int *, int *, int *, int); int LoaderOpen(const char *, const char *, int, int *, int *, int *, int);
int LoaderHandleOpen(int); int LoaderHandleOpen(int);
/* object to name lookup routines */
char *_LoaderHandleToName(int handle);
char *_LoaderHandleToCanonicalName(int handle);
/* Loader backends. */ /* Loader backends. */
#include "dlloader.h" #include "dlloader.h"

View File

@ -98,9 +98,6 @@ LexRec, *LexPtr;
#define parsePrologue(typeptr,typerec) typeptr ptr; \ #define parsePrologue(typeptr,typerec) typeptr ptr; \
if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; } if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; }
#define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \
if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return; }
#define HANDLE_RETURN(f,func)\ #define HANDLE_RETURN(f,func)\
if ((ptr->f=func) == NULL)\ if ((ptr->f=func) == NULL)\
{\ {\
@ -152,10 +149,6 @@ else\
"The %s keyword requires a boolean to follow it." "The %s keyword requires a boolean to follow it."
#define ZAXISMAPPING_MSG \ #define ZAXISMAPPING_MSG \
"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it." "The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it."
#define AUTOREPEAT_MSG \
"The AutoRepeat keyword requires 2 numbers (delay and rate) to follow it."
#define XLEDS_MSG \
"The XLeds keyword requries one or more numbers to follow it."
#define DACSPEED_MSG \ #define DACSPEED_MSG \
"The DacSpeed keyword must be followed by a list of up to %d numbers." "The DacSpeed keyword must be followed by a list of up to %d numbers."
#define DISPLAYSIZE_MSG \ #define DISPLAYSIZE_MSG \
@ -216,7 +209,5 @@ else\
/* Warning messages */ /* Warning messages */
#define OBSOLETE_MSG \ #define OBSOLETE_MSG \
"Ignoring obsolete keyword \"%s\"." "Ignoring obsolete keyword \"%s\"."
#define MOVED_TO_FLAGS_MSG \
"Keyword \"%s\" is now an Option flag in the ServerFlags section."
#endif /* _Configint_h_ */ #endif /* _Configint_h_ */

View File

@ -132,7 +132,6 @@ xf86parseFlagsSection (void)
if (ServerFlagsTab[i].token == token) if (ServerFlagsTab[i].token == token)
{ {
char *valstr = NULL; char *valstr = NULL;
/* can't use strdup because it calls malloc */
tmp = strdup (ServerFlagsTab[i].name); tmp = strdup (ServerFlagsTab[i].name);
if (hasvalue) if (hasvalue)
{ {
@ -365,13 +364,8 @@ xf86optionListCreate( const char **options, int count, int used )
} }
for (i = 0; i < count; i += 2) for (i = 0; i < count; i += 2)
{ {
/* can't use strdup because it calls malloc */ t1 = strdup(options[i]);
t1 = malloc (sizeof (char) * t2 = strdup(options[i + 1]);
(strlen (options[i]) + 1));
strcpy (t1, options[i]);
t2 = malloc (sizeof (char) *
(strlen (options[i + 1]) + 1));
strcpy (t2, options[i + 1]);
p = addNewOption2 (p, t1, t2, used); p = addNewOption2 (p, t1, t2, used);
} }

View File

@ -819,6 +819,7 @@ OpenConfigFile(const char *path, const char *cmdline, const char *projroot,
} }
} }
free(pathcopy);
if (file) { if (file) {
configFiles[numFiles].file = file; configFiles[numFiles].file = file;
configFiles[numFiles].path = strdup(filepath); configFiles[numFiles].path = strdup(filepath);
@ -927,6 +928,7 @@ OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
} }
} }
free(pathcopy);
return dirpath; return dirpath;
} }
@ -1088,8 +1090,7 @@ void
xf86setSection (char *section) xf86setSection (char *section)
{ {
free(configSection); free(configSection);
configSection = malloc(strlen (section) + 1); configSection = strdup(section);
strcpy (configSection, section);
} }
/* /*

View File

@ -479,12 +479,11 @@ static void setup_env(void) {
pds = LAUNCHD_ID_PREFIX".X11"; pds = LAUNCHD_ID_PREFIX".X11";
} }
server_bootstrap_name = malloc(sizeof(char) * (strlen(pds) + 1)); server_bootstrap_name = strdup(pds);
if(!server_bootstrap_name) { if(!server_bootstrap_name) {
fprintf(stderr, "X11.app: Memory allocation error.\n"); fprintf(stderr, "X11.app: Memory allocation error.\n");
exit(1); exit(1);
} }
strcpy(server_bootstrap_name, pds);
setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1); setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1);
len = strlen(server_bootstrap_name); len = strlen(server_bootstrap_name);

View File

@ -444,7 +444,7 @@ glxLogExtensions(const char *prefix, const char *extensions)
{ {
int length = 0; int length = 0;
char *strl; char *strl;
char *str = malloc(strlen(extensions) + 1); char *str = strdup(extensions);
if (str == NULL) if (str == NULL)
{ {
@ -452,9 +452,6 @@ glxLogExtensions(const char *prefix, const char *extensions)
return; return;
} }
str[strlen(extensions)] = '\0';
strncpy (str, extensions, strlen(extensions));
strl = strtok(str, " "); strl = strtok(str, " ");
ErrorF("%s%s", prefix, strl); ErrorF("%s%s", prefix, strl);
length = strlen(prefix) + strlen(strl); length = strlen(prefix) + strlen(strl);