FILE *fp; /* for pid_fname */
char *afs_weblog_pidfile;
- char *httpd_pid_fname = (char *)malloc(strlen(pf) + 1);
+ char *httpd_pid_fname = strdup(pf);
if (httpd_pid_fname == NULL) {
fprintf(stderr,
"%s: malloc failed - out of memory while allocating space for httpd_pid_fname\n",
module_name);
exit(-1);
}
- strcpy(httpd_pid_fname, pf);
afs_weblog_pidfile = (char *)malloc(strlen(httpd_pid_fname) + 5);
if (httpd_pid_fname == NULL) {
fprintf(stderr,
free(tbnodep->lastErrorName);
tbnodep->lastErrorName = NULL;
}
- if (ap->coreName) {
- tbnodep->lastErrorName = (char *)malloc(strlen(ap->coreName) + 1);
- strcpy(tbnodep->lastErrorName, ap->coreName);
- }
+ if (ap->coreName)
+ tbnodep->lastErrorName = strdup(ap->coreName);
}
/* utility for use by BOP_HASCORE functions to determine where a core file might
/* format the bnode properly */
memset(abnode, 0, sizeof(struct bnode));
abnode->ops = abnodeops;
- abnode->name = (char *)malloc(strlen(aname) + 1);
+ abnode->name = strdup(aname);
if (!abnode->name)
return ENOMEM;
- strcpy(abnode->name, aname);
abnode->flags = BNODE_ACTIVE;
abnode->fileGoal = BSTAT_NORMAL;
abnode->goal = BSTAT_SHUTDOWN;
ttok =
(struct bnode_token *)malloc(sizeof(struct bnode_token));
ttok->next = (struct bnode_token *)0;
- ttok->key = (char *)malloc(strlen(tbuffer) + 1);
- strcpy(ttok->key, tbuffer);
+ ttok->key = strdup(tbuffer);
if (last) {
last->next = ttok;
last = ttok;
*aname = (char *)malloc(1);
**aname = 0;
} else {
- *aname = (char *)malloc(strlen(tname) + 1);
- strcpy(*aname, tname);
+ *aname = strdup(tname);
}
return code;
/* now, return the appropriate error string, if any */
if (tb->lastErrorName) {
- *as1 = (char *)malloc(strlen(tb->lastErrorName) + 1);
- strcpy(*as1, tb->lastErrorName);
+ *as1 = strdup(tb->lastErrorName);
} else {
*as1 = (char *)malloc(1);
**as1 = 0;
int initBosEntryStats(void);
int DirAccessOK(void);
-/* fsbnodeops.c */
-char *copystr(char *a);
-
/* inline functions */
static_inline struct bozo_key *
ktc_to_bozoptr(struct ktc_encryptionKey *key) {
}
te->when = ktime_next(&te->whenToRun, 0);
te->command = cmdpath;
- te->whenString = copystr(awhen);
+ te->whenString = strdup(awhen);
return (struct bnode *)te;
}
return 0;
}
-char *
-copystr(char *a)
-{
- char *b;
- b = (char *)malloc(strlen(a) + 1);
- strcpy(b, a);
- return b;
-}
-
static int
fs_delete(struct bnode *bn)
{
char *
bc_CopyString(char *astring)
{
- afs_int32 tlen;
char *tp;
if (!astring)
return (NULL); /* propagate null strings easily */
- tlen = strlen(astring);
- tp = (char *)malloc(tlen + 1); /* don't forget the terminating null */
+ tp = strdup(astring);
if (!tp) {
afs_com_err(whoami, BC_NOMEM, NULL);
return (tp);
}
- strcpy(tp, astring);
return tp;
}
* global variables so this can take place in main.
*/
if (loadfile) {
- loadFile = (char *)malloc(strlen(as->parms[6].items->data) + 1);
+ loadFile = strdup(as->parms[6].items->data);
if (!loadFile) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
}
- strcpy(loadFile, as->parms[6].items->data);
return 0;
}
bc_globalConfig = tb;
memset(tb, 0, sizeof(struct bc_config));
- tb->path = (char *)malloc(strlen(apath) + 1);
+ tb->path = strdup(apath);
if (!tb->path) {
free(tb);
return (BC_NOMEM);
}
- strcpy(tb->path, apath);
-
/* now read the important config files; no file means empty list during system init */
return 0;
/* tlast now points to the next pointer (or head pointer) we should overwrite */
tentry = (struct bc_hostEntry *)malloc(sizeof(struct bc_hostEntry));
memset(tentry, 0, sizeof(*tentry));
- tentry->name = (char *)malloc(strlen(aname) + 1);
- strcpy(tentry->name, aname);
+ tentry->name = strdup(aname);
*tlast = tentry;
tentry->next = (struct bc_hostEntry *)0;
tentry->addr.sin_family = AF_INET;
nset = (struct bc_volumeSet *)malloc(sizeof(struct bc_volumeSet));
memset(nset, 0, sizeof(*nset));
nset->flags = aflags;
- nset->name = (char *)malloc(strlen(avolName) + 1);
- strcpy(nset->name, avolName);
+ nset->name = strdup(avolName);
if (aflags & VSFLAG_TEMPORARY) {
/* Add to beginning of list */
nset->next = aconfig->vset;
for (tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast);
tentry = (struct bc_volumeEntry *)malloc(sizeof(struct bc_volumeEntry));
memset(tentry, 0, sizeof(*tentry));
- tentry->serverName = (char *)malloc(strlen(ahost) + 1);
- strcpy(tentry->serverName, ahost);
- tentry->partname = (char *)malloc(strlen(apart) + 1);
- strcpy(tentry->partname, apart);
- tentry->name = (char *)malloc(strlen(avol) + 1);
- strcpy(tentry->name, avol);
+ tentry->serverName = strdup(ahost);
+ tentry->partname = strdup(apart);
+ tentry->name = strdup(avol);
code = bc_ParseHost(tentry->serverName, &tentry->server);
if (code)
aconfig->dsched = tdump;
/* save the name of this dump node */
- tdump->name = (char *)malloc(strlen(adumpName) + 1);
- strcpy(tdump->name, adumpName);
+ tdump->name = strdup(adumpName);
/* expiration information */
tdump->expDate = expDate;
memset(tds, 0, sizeof(*tds));
tds->next = (struct bc_dumpSchedule *)0;
- tds->name = (char *)malloc(strlen(dsname) + 1);
- strcpy(tds->name, dsname);
+ tds->name = strdup(dsname);
tds->expDate = expDate;
tds->expType = expType;
}
memset(vi, 0, sizeof(struct volinfo));
- vi->volname = (char *)malloc(strlen(vname) + 1);
+ vi->volname = strdup(vname);
if (!vi->volname) {
free(vi);
afs_com_err(whoami, BC_NOMEM, NULL);
ERROR(BC_NOMEM);
}
- strcpy(vi->volname, vname);
if (serverAll) {
vi->server = serverAll;
vi->partition = partitionAll;
}
memset(tle, 0, sizeof(struct bc_tapeList));
- tle->tapeName =
- (char *)malloc(strlen(volumeEntries[ve].tape)
- + 1);
+ tle->tapeName = strdup(volumeEntries[ve].tape);
if (!tle->tapeName) {
free(tle);
afs_com_err(whoami, BC_NOMEM, NULL);
return (BC_NOMEM);
}
- strcpy(tle->tapeName, volumeEntries[ve].tape);
tle->dumpID = dlevels[lv].DumpId;
tle->initialDumpID = dlevels[lv].initialDumpId;
tle->tapeNumber = tapeseq;
}
memset(ti, 0, sizeof(struct bc_tapeItem));
- ti->volumeName =
- (char *)malloc(strlen(volumeEntries[ve].name)
- + 1);
+ ti->volumeName = strdup(volumeEntries[ve].name);
if (!ti->volumeName) {
free(ti);
afs_com_err(whoami, BC_NOMEM, NULL);
return (BC_NOMEM);
}
- strcpy(ti->volumeName, volumeEntries[ve].name);
ti->server = vi->server;
ti->partition = vi->partition;
ti->oid = volumeEntries[ve].id;
tfirst = tlast = the;
}
the->next = (struct bc_hostEntry *)0;
- the->name = (char *)malloc(strlen(hostName) + 1);
- strcpy(the->name, hostName);
+ the->name = strdup(hostName);
the->portOffset = port;
if (th) {
memcpy(&the->addr.sin_addr.s_addr, th->h_addr, 4);
*/
tvs = (struct bc_volumeSet *)malloc(sizeof(struct bc_volumeSet));
memset(tvs, 0, sizeof(*tvs));
- tvs->name = (char *)malloc(strlen(vsname) + 1);
- strcpy(tvs->name, vsname);
+ tvs->name = strdup(vsname);
/* append to the end */
for (ppvs = &bc_globalConfig->vset, pvs = *ppvs; pvs;
/* The above code has filled in the server sockaddr, now fill in
* the rest of the fields.
*/
- tve->serverName = (char *)malloc(strlen(serverName) + 1);
+ tve->serverName = strdup(serverName);
if (!tve->serverName) {
afs_com_err(whoami, 0,
"Can't malloc() a new volume spec server name field!");
return (-1);
}
- strcpy(tve->serverName, serverName);
- tve->partname = (char *)malloc(strlen(partName) + 1);
+ tve->partname = strdup(partName);
if (!tve->partname) {
afs_com_err(whoami, 0,
"Can't malloc() a new volume spec partition pattern field!");
return (-1);
}
- strcpy(tve->partname, partName);
code = bc_GetPartitionID(partName, &tve->partition);
if (code) {
afs_com_err(whoami, 0, "Can't parse partition '%s'", partName);
return -1;
}
- tp = (char *)malloc(strlen(vsname) + 1);
+ tp = strdup(vsname);
if (!tp) {
afs_com_err(whoami, 0,
"Can't malloc() a new volume spec volume pattern field!");
return (-1);
}
- strcpy(tp, vsname);
tve->name = tp;
/* Now, thread it onto the list of other volume spec entries for
/* database directory */
if (as->parms[0].items != 0) {
- globalConfPtr->databaseDirectory =
- (char *)malloc(strlen(as->parms[0].items->data) + 1);
+ globalConfPtr->databaseDirectory = strdup(as->parms[0].items->data);
if (globalConfPtr->databaseDirectory == 0)
BUDB_EXIT(-1);
- strcpy(globalConfPtr->databaseDirectory, as->parms[0].items->data);
}
/* -cellservdb, cell configuration directory */
if (as->parms[1].items != 0) {
- globalConfPtr->cellConfigdir =
- (char *)malloc(strlen(as->parms[1].items->data) + 1);
+ globalConfPtr->cellConfigdir = strdup(as->parms[1].items->data);
if (globalConfPtr->cellConfigdir == 0)
BUDB_EXIT(-1);
- strcpy(globalConfPtr->cellConfigdir, as->parms[1].items->data);
-
globalConfPtr->debugFlags |= DF_RECHECKNOAUTH;
}
continue;
}
- opencallout = (char *)malloc(strlen(value) + 1);
- strcpy(opencallout, value);
+ opencallout = strdup(value);
printf("Tape mount callout routine is %s\n", opencallout);
}
continue;
}
- closecallout = (char *)malloc(strlen(value) + 1);
- strcpy(closecallout, value);
+ closecallout = strdup(value);
printf("Tape unmount callout routine is %s\n", closecallout);
}
cmd);
continue;
}
- xbsaObjectOwner = malloc(strlen(value) + 1);
- strcpy(xbsaObjectOwner, value);
+ xbsaObjectOwner = strdup(value);
printf("XBSA node is %s\n", xbsaObjectOwner);
}
cmd);
continue;
}
- adsmServerName = malloc(strlen(value) + 1);
- strcpy(adsmServerName, value);
+ adsmServerName = strdup(value);
printf("XBSA server is %s\n", adsmServerName);
}
continue;
}
- xbsaSecToken = malloc(strlen(value) + 1);
- strcpy(xbsaSecToken, value);
+ xbsaSecToken = strdup(value);
printf("XBSA Password has been read\n");
}
cmd);
continue;
}
- xbsalGName = malloc(strlen(value) + 1);
- strcpy(xbsalGName, value);
+ xbsalGName = strdup(value);
printf("XBSA management class is %s\n", xbsalGName);
}
#endif
}
else if (!strcmp(cmd, "CENTRALLOG")) {
- centralLogFile = malloc(strlen(value) + 1);
- strcpy(centralLogFile, value);
+ centralLogFile = strdup(value);
printf("Central log file is %s\n", centralLogFile);
}
}
if (as->parms[6].items) { /* -restoretofile */
- int s = strlen(as->parms[6].items->data);
- restoretofile = malloc(s + 1);
- strncpy(restoretofile, as->parms[6].items->data, s + 1);
+ restoretofile = strdup(as->parms[6].items->data);
printf("Restore to file '%s'\n", restoretofile);
}
/*set up the parameters in the node, to be used by LWP */
strcpy(newNode->dumpSetName, tcdiPtr->dumpName);
- newNode->dumpName = (char *)malloc(strlen(tcdiPtr->dumpPath) + 1);
- strcpy(newNode->dumpName, tcdiPtr->dumpPath);
-
- newNode->volumeSetName =
- (char *)malloc(strlen(tcdiPtr->volumeSetName) + 1);
- strcpy(newNode->volumeSetName, tcdiPtr->volumeSetName);
+ newNode->dumpName = strdup(tcdiPtr->dumpPath);
+ newNode->volumeSetName = strdup(tcdiPtr->volumeSetName);
CopyTapeSetDesc(&(newNode->tapeSetDesc), &tcdiPtr->tapeSet);
/* copy in name, etc */
if (aname) {
- td->name = malloc(strlen(aname) + 1);
+ td->name = strdup(aname);
assert(td->name);
- strcpy(td->name, aname);
} else {
td->name = NULL;
noOpcodes = 1;
if (ahelp == (char *)CMD_HIDDEN) {
td->flags |= CMD_HIDDEN;
} else {
- td->help = malloc(strlen(ahelp) + 1);
+ td->help = strdup(ahelp);
assert(td->help);
- strcpy(td->help, ahelp);
}
} else
td->help = NULL;
td = malloc(sizeof(struct cmd_syndesc));
assert(td);
memcpy(td, as, sizeof(struct cmd_syndesc));
- td->name = malloc(strlen(aname) + 1);
+ td->name = strdup(aname);
assert(td->name);
- strcpy(td->name, aname);
td->flags |= CMD_ALIAS;
/* if ever free things, make copy of help string, too */
return CMD_EXCESSPARMS;
tp = &as->parms[ref];
- tp->name = malloc(strlen(aname) + 1);
+ tp->name = strdup(aname);
assert(tp->name);
- strcpy(tp->name, aname);
tp->type = atype;
tp->flags = aflags;
tp->items = NULL;
if (ahelp) {
- tp->help = malloc(strlen(ahelp) + 1);
+ tp->help = strdup(ahelp);
assert(tp->help);
- strcpy(tp->help, ahelp);
} else
tp->help = NULL;
ti = calloc(1, sizeof(struct cmd_item));
assert(ti);
- ti->data = malloc(strlen(aval) + 1);
+ ti->data = strdup(aval);
assert(ti->data);
- strcpy(ti->data, aval);
/* now put ti at the *end* of the list */
if ((ni = aparm->items)) {
for (; ni; ni = ni->next)
}
/* Create space for the initial opcode & fill it in */
- pinitopcode = malloc(sizeof(initcmd_opcode));
+ pinitopcode = strdup(initcmd_opcode);
if (!pinitopcode) {
fprintf(stderr, "%s: Can't malloc initial opcode space\n", aargv[0]);
free(newargv);
return (NULL);
}
- strcpy(pinitopcode, initcmd_opcode);
/* Move all the items in the old argv into the new argv, in their
* proper places */
count = 0;
if (amaxn <= 1)
return CMD_TOOMANY;
- *argv = (char *)malloc(strlen(INITSTR) + 1);
+ *argv = strdup(INITSTR);
assert(*argv);
- strcpy(*argv, INITSTR);
amaxn--;
argv++;
count++;
ttok = malloc(sizeof(struct cmd_token));
assert(ttok);
ttok->next = NULL;
- ttok->key = malloc(strlen(tbuffer) + 1);
+ ttok->key = strdup(tbuffer);
assert(ttok->key);
- strcpy(ttok->key, tbuffer);
if (last) {
last->next = ttok;
last = ttok;
char *current_token = (char *)NULL;
extern char *table_name;
-char *ds(const char *string);
char *quote(const char *string);
void set_table_1num(char *string);
int char_to_1num(char c);
%%
error_table : ERROR_TABLE header error_codes END
- { table_name = ds($2);
+ { table_name = strdup($2);
current_token = table_name;
put_ecs(); }
;
$$ = $2; }
| table_id
{ current_token = $1;
- set_table_fun(ds("1"));
+ set_table_fun(strdup("1"));
$$ = $1;
}
;
;
ec_name : STRING
- { $$ = ds($1);
+ { $$ = strdup($1);
current_token = $$; }
;
description : QUOTED_STRING
- { $$ = ds($1);
+ { $$ = strdup($1);
current_token = $$; }
;
return(symbol);
}
-char *
-ds(const char *string)
-{
- char *rv;
- rv = (char *)malloc(strlen(string)+1);
- strcpy(rv, string);
- return(rv);
-}
-
char *
quote(const char *string)
{
char *rv;
- rv = (char *)malloc(strlen(string)+3);
+ rv = malloc(strlen(string)+3);
strcpy(rv, "\"");
strcat(rv, string);
strcat(rv, "\"");
}
error_codes = (char **)realloc((char *)error_codes,
(current + 2)*sizeof(char *));
- error_codes[current++] = ds(name);
+ error_codes[current++] = strdup(name);
error_codes[current] = (char *)NULL;
}
}
error_codes = (char **)realloc((char *)error_codes,
(current + 2)*sizeof(char *));
- error_codes[current++] = ds(name);
+ error_codes[current++] = strdup(name);
error_codes[current] = (char *)NULL;
}
char *current_token = (char *)NULL;
extern char *table_name;
-char *ds(const char *string);
char *quote(const char *string);
void set_table_1num(char *string);
int char_to_1num(char c);
case 1:
#line 51 "error_table.y"
{
- table_name = ds(yyvsp[-2].dynstr);
+ table_name = strdup(yyvsp[-2].dynstr);
current_token = table_name;
put_ecs();;
break;
#line 60 "error_table.y"
{
current_token = yyvsp[0].dynstr;
- set_table_fun(ds("1"));
+ set_table_fun(strdup("1"));
yyval.dynstr = yyvsp[0].dynstr;
;
break;
case 10:
#line 96 "error_table.y"
{
- yyval.dynstr = ds(yyvsp[0].dynstr);
+ yyval.dynstr = strdup(yyvsp[0].dynstr);
current_token = yyval.dynstr;;
break;
}
case 11:
#line 101 "error_table.y"
{
- yyval.dynstr = ds(yyvsp[0].dynstr);
+ yyval.dynstr = strdup(yyvsp[0].dynstr);
current_token = yyval.dynstr;;
break;
}
return (symbol);
}
-char *
-ds(const char *string)
-{
- char *rv;
- rv = (char *)malloc(strlen(string) + 1);
- strcpy(rv, string);
- return (rv);
-}
-
char *
quote(const char *string)
{
}
error_codes =
(char **)realloc((char *)error_codes, (current + 2) * sizeof(char *));
- error_codes[current++] = ds(name);
+ error_codes[current++] = strdup(name);
error_codes[current] = (char *)NULL;
}
}
error_codes =
(char **)realloc((char *)error_codes, (current + 2) * sizeof(char *));
- error_codes[current++] = ds(name);
+ error_codes[current++] = strdup(name);
error_codes[current] = (char *)NULL;
}
[\t\n\r ] ;
-\"{PC}*\" { char *p; yylval.dynstr = ds((char *)yytext+1);
+\"{PC}*\" { char *p; yylval.dynstr = strdup((char *)yytext+1);
if ((p=strrchr(yylval.dynstr, '"'))) *p='\0';
return QUOTED_STRING;
}
-{AN}* { yylval.dynstr = ds((char *)yytext); return STRING; }
+{AN}* { yylval.dynstr = strdup((char *)yytext); return STRING; }
#.*\n ;
case 7:
YY_RULE_SETUP
#line 13 "et_lex.lex.l"
-{ char *p; yylval.dynstr = ds((char *)yytext+1);
+{ char *p; yylval.dynstr = strdup((char *)yytext+1);
if (p=strrchr(yylval.dynstr, '"')) *p='\0';
return QUOTED_STRING;
}
case 8:
YY_RULE_SETUP
#line 18 "et_lex.lex.l"
-{ yylval.dynstr = ds((char *)yytext); return STRING; }
+{ yylval.dynstr = strdup((char *)yytext); return STRING; }
YY_BREAK
case 9:
YY_RULE_SETUP
ttok = (struct token *)malloc(sizeof(struct token));
ttok->next = NULL;
if (dontUse) {
- ttok->key = (char *)malloc(strlen(tbuffer));
- strcpy(ttok->key, tbuffer + 1);
+ ttok->key = strdup(tbuffer + 1); /* Skip first char */
ttok->flags = TOK_DONTUSE;
dontUse = 0;
} else {
- ttok->key = (char *)malloc(strlen(tbuffer) + 1);
- strcpy(ttok->key, tbuffer);
+ ttok->key = strdup(tbuffer);
ttok->flags = 0;
}
if (last) {
char *
gtx_CopyString(char *aval)
{
- char *tp;
-
if (!aval)
return NULL; /* propagate null strings around */
- tp = (char *)malloc(strlen(aval) + 1);
- if (tp != NULL)
- strcpy(tp, aval);
- return (tp);
+ return strdup(aval);
}
static int
return code;
}
ip = (struct cmd_item *)malloc(sizeof(struct cmd_item));
- ip->data = (char *)malloc(strlen(password) + 1);
+ ip->data = strdup(password);
ip->next = 0;
- strcpy(ip->data, password);
as->parms[i].items = ip;
}
}
if (tst == 0 && clientSt == 0) {
/* everything looks good; malloc cell name buffer to return */
- clientCellName =
- (char *)malloc(strlen(cellentry->cellInfo.name) + 1);
- if (clientCellName == NULL) {
+ clientCellName = strdup(cellentry->cellInfo.name);
+ if (clientCellName == NULL)
tst = ADMNOMEM;
- } else {
- strcpy(clientCellName, cellentry->cellInfo.name);
- }
}
(void)afsconf_Close(confdir);
/* return cell name to caller */
if (tst == 0) {
- *cellName = (char *)malloc(strlen(dbhostCell) + 1);
+ *cellName = strdup(dbhostCell);
if (*cellName == NULL) {
free(*cellDbHosts);
- *cellDbHosts = NULL;
+ *cellDbHosts = NULL;
tst = ADMNOMEM;
- } else {
- strcpy(*cellName, dbhostCell);
}
}
}
if (tst == 0 && serverSt == 0) {
/* everything looks good; malloc cell name buffer to return */
- serverCellName =
- (char *)malloc(strlen(cellentry->cellInfo.name) + 1);
- if (serverCellName == NULL) {
+ serverCellName = strdup(cellentry->cellInfo.name);
+ if (serverCellName == NULL)
tst = ADMNOMEM;
- } else {
- strcpy(serverCellName, cellentry->cellInfo.name);
- }
}
(void)afsconf_Close(confdir);
if ((cfg_host = (cfg_host_p) malloc(sizeof(cfg_host_t))) == NULL) {
tst = ADMNOMEM;
- } else if ((localHostName = (char *)malloc(strlen(fullHostName) + 1))
- == NULL) {
+ } else if ((localHostName = strdup(fullHostName)) == NULL) {
free(cfg_host);
tst = ADMNOMEM;
} else {
cfg_host->bosHandle = NULL;
cfg_host->end_magic = END_MAGIC;
- strcpy(localHostName, fullHostName);
-
if (!afsclient_CellNameGet
(cfg_host->cellHandle, &cfg_host->cellName, &tst2)) {
tst = tst2;
*tptr++ = 0;
ttok = (struct token *)malloc(sizeof(struct token));
ttok->next = NULL;
- ttok->key = (char *)malloc(strlen(tbuffer) + 1);
- strcpy(ttok->key, tbuffer);
+ ttok->key = strdup(tbuffer);
if (last) {
last->next = ttok;
last = ttok;
int async_nProcs = 0;
-char *
-allocString(s)
- char *s;
-{
- char *new = (char *)malloc(strlen(s) + 1);
- strcpy(new, s);
- return new;
-}
-
void
async_BulkProc(data)
char *data;
name++;
/* sprintf(tempfile, "/usr/tmp/%s.%s", myHostName, name);*/
sprintf(tempfile, "/usr/tmp/%s", name);
- work->local = allocString(store ? file : tempfile);
- work->remote = allocString(store ? tempfile : file);
+ work->local = strdup(store ? file : tempfile);
+ work->remote = strdup(store ? tempfile : file);
async_nProcs += 1;
LWP_CreateProcess(async_BulkProc, 3000, RX_PROCESS_PRIORITY, (void *)work,
"bulk", &pid);
} else if (s->vnode) { /* Search by vnode */
if (de->vnode != s->vnode[0]) return 0; /* Not it! */
if (s->name) {
- s->name[0] = (char *)malloc(strlen(de->name) + 1);
+ s->name[0] = strdup(de->name);
if (!s->name[0]) return ENOMEM;
- strcpy(s->name[0], de->name);
}
if (s->vuniq) s->vuniq[0] = de->uniq;
}
int nl, pl = 0;
if (vnode == 1) {
- *his_path = (char *)malloc(2);
+ *his_path = strdup("/");
if (!his_path) {
if (phi->p->cb_error)
(phi->p->cb_error) (ENOMEM, 1, phi->p->err_refcon,
"No memory for pathname of vnode 1");
return ENOMEM;
}
- strcpy(*his_path, "/");
return 0;
}
fprintf(stderr, ">>> Will use RESTORED.%d\n", hdr->volid);
}
sprintf(volname, "RESTORED.%d", hdr->volid);
- hdr->volname = (unsigned char *)malloc(strlen(volname) + 1);
+ hdr->volname = (unsigned char *) strdup(volname);
if (!hdr->volname)
return ENOMEM;
- strcpy((char *)hdr->volname, volname);
hdr->field_mask |= F_DUMPHDR_VOLNAME;
}
if (!(field_mask & F_DUMPHDR_FROM)) {
fprintf(stderr, ">>> Will use RESTORED.%d\n", hdr->volid);
}
sprintf(volname, "RESTORED.%d", hdr->volid);
- hdr->volname = (unsigned char *)malloc(strlen(volname) + 1);
+ hdr->volname = (unsigned char *)strdup(volname);
if (!hdr->volname)
return ENOMEM;
- strcpy((char *)hdr->volname, volname);
hdr->field_mask |= F_VOLHDR_VOLNAME;
}
if (!(field_mask & F_VOLHDR_INSERV)) {
hdr->magic = ntohl(bckhdr->c_magic);
hdr->cksum = ntohl(bckhdr->c_checksum);
hdr->flags = ntohl(bckhdr->c_flags);
- hdr->server = malloc(strlen(bckhdr->c_host) + 1);
- hdr->part = malloc(strlen(bckhdr->c_disk) + 1);
- hdr->volname = malloc(strlen(bckhdr->c_name) + 1);
+ hdr->server = (unsigned char *) strdup(bckhdr->c_host);
+ hdr->part = (unsigned char *) strdup(bckhdr->c_disk);
+ hdr->volname = (unsigned char *) strdup(bckhdr->c_name);
if (!hdr->server || !hdr->part || !hdr->volname) {
if (hdr->server)
free(hdr->volname);
return ENOMEM;
}
- strcpy((char *)hdr->server, bckhdr->c_host);
- strcpy((char *)hdr->part, bckhdr->c_disk);
- strcpy((char *)hdr->volname, bckhdr->c_name);
}
if (tag)
initialize_U_error_table();
tdb = (struct ubik_dbase *)malloc(sizeof(struct ubik_dbase));
- tdb->pathName = (char *)malloc(strlen(pathName) + 1);
- strcpy(tdb->pathName, pathName);
+ tdb->pathName = strdup(pathName);
tdb->activeTrans = (struct ubik_trans *)0;
memset(&tdb->version, 0, sizeof(struct ubik_version));
memset(&tdb->cachedVersion, 0, sizeof(struct ubik_version));
tf = (struct filestr *)malloc(sizeof(struct filestr));
tf->next = *ah;
*ah = tf;
- tf->name = (char *)malloc(strlen(aname) + 1);
- strcpy(tf->name, aname);
+ tf->name = strdup(aname);
return 0;
}
usd->seek = usd_FileSeek;
usd->ioctl = usd_FileIoctl;
usd->close = usd_FileClose;
- usd->fullPathName = (char *)malloc(strlen(path) + 1);
- strcpy(usd->fullPathName, path);
+ usd->fullPathName = strdup(path);
usd->openFlags = flags;
code = 0;
usd->ioctl = usd_DeviceIoctl;
usd->close = usd_DeviceClose;
- usd->fullPathName = (char *)malloc(strlen(path) + 1);
- strcpy(usd->fullPathName, path);
+ usd->fullPathName = strdup(path);
usd->openFlags = oflag;
/* For devices, this is the first real reference, so many errors show up
*/
new_dir = (struct uss_subdir *)malloc(sizeof(struct uss_subdir));
new_dir->previous = uss_currentDir;
- new_dir->path = (char *)malloc(strlen(a_path) + 1);
- strcpy(new_dir->path, a_path);
- new_dir->finalACL = (char *)malloc(strlen(a_access) + 1);
- strcpy(new_dir->finalACL, a_access);
+ new_dir->path = strdup(a_path);
+ new_dir->finalACL = strdup(a_access);
uss_currentDir = new_dir;
/*
*/
new_dir = (struct uss_subdir *)malloc(sizeof(struct uss_subdir));
new_dir->previous = uss_currentDir;
- new_dir->path = (char *)malloc(strlen(a_mpoint) + 1);
- strcpy(new_dir->path, a_mpoint);
- new_dir->finalACL = (char *)malloc(strlen(a_acl) + 1);
- strcpy(new_dir->finalACL, a_acl);
+ new_dir->path = strdup(a_mpoint);
+ new_dir->finalACL = strdup(a_acl);
uss_currentDir = new_dir;
sprintf(tmp_str, "%s %s all", a_mpoint, uss_AccountCreator);
status = EINVAL;
} else {
/* fully qualified path; just make a copy */
- newPath = (char *)malloc(strlen(cpath) + 1);
- if (!newPath) {
+ newPath = strdup(cpath);
+ if (!newPath)
status = ENOMEM;
- } else {
- (void)strcpy(newPath, cpath);
- }
}
} else {
LocalizePathHead(&cpath, &relativeTo);
if (*cpath == '/') {
- newPath = (char *)malloc(strlen(cpath) + 1);
- if (!newPath) {
+ newPath = strdup(cpath);
+ if (!newPath)
status = ENOMEM;
- } else {
- strcpy(newPath, cpath);
- }
} else {
newPath = (char *)malloc(strlen(relativeTo) + 1 + strlen(cpath) + 1);
if (!newPath) {
*tptr++ = 0;
ttok = malloc(sizeof(struct token));
ttok->next = NULL;
- ttok->key = malloc(strlen(tbuffer) + 1);
- strcpy(ttok->key, tbuffer);
+ ttok->key = strdup(tbuffer);
if (last) {
last->next = ttok;
last = ttok;
memset(lip, 0, sizeof(*lip));
lip->nextp = allInfo;
allInfo = lip;
- lip->name = (char *)malloc(strlen(tname) + 1);
- strcpy(lip->name, tname);
+ lip->name = strdup(tname);
}
i = found;
} else {
memset(lip, 0, sizeof(*lip));
lip->nextp = allInfo;
allInfo = lip;
- lip->name = (char *)malloc(strlen(tname) + 1);
- strcpy(lip->name, tname);
+ lip->name = strdup(tname);
}
}
if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL)
errexit("out of memory");
dk = *dkp;
- if ((dk->name = malloc((unsigned int)len + 1)) == NULL)
+ if ((dk->name = strdup(name)) == NULL)
errexit("out of memory");
- strncpy(dk->name, name, len);
- dk->name[len] = '\0';
dk->part = NULL;
dk->next = NULL;
dk->pid = 0;
if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL)
errexit("out of memory");
pt = *ppt;
- if ((pt->name = malloc((unsigned int)strlen(name) + 1)) == NULL)
+ if ((pt->name = strdup(name)) == NULL)
errexit("out of memory");
- strcpy(pt->name, name);
- if ((pt->fsname = malloc((unsigned int)strlen(fsname) + 1)) == NULL)
+ if ((pt->fsname = strdup(fsname)) == NULL)
errexit("out of memory");
- strcpy(pt->fsname, fsname);
pt->next = NULL;
}
RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg,
char **motd, Volume * volptr)
{
- int temp;
status->Vid = V_id(volptr);
status->ParentId = V_parentId(volptr);
status->PartMaxBlocks = RoundInt64ToInt31(volptr->partition->totalUsable);
/* now allocate and copy these things; they're freed by the RXGEN stub */
- temp = strlen(V_name(volptr)) + 1;
- *name = malloc(temp);
+ *name = strdup(V_name(volptr));
if (!*name) {
ViceLogThenPanic(0, ("Failed malloc in RXGetVolumeStatus\n"));
}
- strcpy(*name, V_name(volptr));
- temp = strlen(V_offlineMessage(volptr)) + 1;
- *offMsg = malloc(temp);
+ *offMsg = strdup(V_offlineMessage(volptr));
if (!*offMsg) {
ViceLogThenPanic(0, ("Failed malloc in RXGetVolumeStatus\n"));
}
- strcpy(*offMsg, V_offlineMessage(volptr));
*motd = malloc(1);
if (!*motd) {
ViceLogThenPanic(0, ("Failed malloc in RXGetVolumeStatus\n"));
else
DiskPartitionList = dp;
dp->next = 0;
- dp->name = (char *)malloc(strlen(path) + 1);
- strncpy(dp->name, path, strlen(path) + 1);
+ dp->name = strdup(path);
dp->index = volutil_GetPartitionID(path);
#if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
/* Create a lockfile for the partition, of the form /vicepa/Lock/vicepa */
close(afs_open(dp->devName, O_RDWR | O_CREAT, 0600));
dp->device = dp->index;
#else
- dp->devName = (char *)malloc(strlen(devname) + 1);
- strncpy(dp->devName, devname, strlen(devname) + 1);
+ dp->devName = strdup(devname);
dp->device = dev;
#endif
dp->lock_fd = INVALID_FD;
dirEntry->numEntries * sizeof(VnodeName)));
dirEntry->vnodeName[dirEntry->numEntries - 1].vnode = vnode;
dirEntry->vnodeName[dirEntry->numEntries - 1].vunique = unique;
- dirEntry->vnodeName[dirEntry->numEntries - 1].name =
- (char *)malloc(strlen(fileName) + 1);
+ dirEntry->vnodeName[dirEntry->numEntries - 1].name = strdup(fileName);
assert(dirEntry->vnodeName[dirEntry->numEntries - 1].name);
- strcpy(dirEntry->vnodeName[dirEntry->numEntries - 1].name, fileName);
}
char *name;
{
assert(stackSize < MAX_STACK_SIZE);
- assert(stack[stackSize] = (char *)malloc(strlen(name) + 1));
- strcpy(stack[stackSize], name);
+ assert(stack[stackSize] = strdup(name));
stackSize++;
}
Log("FOUND root file: %s" OS_DIRSEP "%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name ? dir->name : "??", name, vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, dir->vnodeNumber);
if (vnodeIdToClass(vnodeNumber) == vLarge
&& vnodeEssence->name == NULL) {
- char *n;
- if ((n = (char *)malloc(strlen(name) + 1)))
- strcpy(n, name);
- vnodeEssence->name = n;
+ vnodeEssence->name = strdup(name);
}
/* The directory entry points to the vnode. Check to see if the
ToString(const char *s)
{
char *p;
- p = (char *)malloc(strlen(s) + 1);
+ p = strdup(s);
osi_Assert(p != NULL);
- strcpy(p, s);
return p;
}