jcs
/subtext
/amendments
/454
util: getpath doesn't need a Str255 *, it's not allocating anything
jcs made amendment 454 about 1 year ago
--- db.c Fri Mar 17 16:15:04 2023
+++ db.c Mon Mar 27 21:52:31 2023
@@ -143,7 +143,7 @@ db_open(Str255 file, short vrefnum)
struct db *ret;
if (file[0]) {
- getpath(vrefnum, file, &filepath, true);
+ getpath(vrefnum, file, filepath, true);
if (FStat(filepath, &sb) == 0)
return db_init(file, vrefnum, NULL);
@@ -230,7 +230,7 @@ db_init(Str255 path, short vrefnum, struct bile *bile)
if (vrefnum == 0)
memcpy(&fullpath, path, sizeof(fullpath));
else
- getpath(vrefnum, path, &fullpath, true);
+ getpath(vrefnum, path, fullpath, true);
lastfileh = Get1Resource('STR ', STR_LAST_DB);
if (lastfileh)
xSetHandleSize(lastfileh, fullpath[0] + 1);
@@ -764,7 +764,7 @@ db_cache_boards(struct db *tdb)
xfree(&tdb->boards);
}
- if (getpath(tdb->bile->vrefnum, tdb->bile->filename, &db_filename,
+ if (getpath(tdb->bile->vrefnum, tdb->bile->filename, db_filename,
false) != 0)
panic("getpath failed on %s", PtoCstr(tdb->bile->filename));
PtoCstr(db_filename);
@@ -868,7 +868,7 @@ db_board_create(struct db *tdb, struct board *board, b
panic("save of new board failed: %d", bile_error(tdb->bile));
xfree(&data);
- if (getpath(tdb->bile->vrefnum, tdb->bile->filename, &db_filename,
+ if (getpath(tdb->bile->vrefnum, tdb->bile->filename, db_filename,
false) != 0)
panic("getpath failed on %s", PtoCstr(tdb->bile->filename));
PtoCstr(db_filename);
@@ -917,7 +917,7 @@ db_cache_folders(struct db *tdb)
xfree(&tdb->folders);
}
- if (getpath(tdb->bile->vrefnum, tdb->bile->filename, &db_filename,
+ if (getpath(tdb->bile->vrefnum, tdb->bile->filename, db_filename,
false) != 0)
panic("getpath failed on %s", PtoCstr(tdb->bile->filename));
PtoCstr(db_filename);
@@ -965,8 +965,7 @@ db_cache_folders(struct db *tdb)
PtoCstr(folder_filename);
if (bile_error(NULL) != fnfErr &&
- ask("Attempt recovery of %s with backup map?",
- folder_filename)) {
+ ask("Attempt recovery of %s with backup map?", folder_filename)) {
CtoPstr(folder_filename);
tdb->folders[n].bile = bile_open_recover_map(folder_filename,
tdb->bile->vrefnum);
@@ -1018,7 +1017,7 @@ db_folder_create(struct db *tdb, struct folder *folder
panic("save of new folder failed: %d", bile_error(tdb->bile));
xfree(&data);
- if (getpath(tdb->bile->vrefnum, tdb->bile->filename, &db_filename,
+ if (getpath(tdb->bile->vrefnum, tdb->bile->filename, db_filename,
false) != 0)
panic("getpath failed on %s", PtoCstr(tdb->bile->filename));
PtoCstr(db_filename);
--- util.c Sun Mar 26 22:10:00 2023
+++ util.c Mon Mar 27 21:32:52 2023
@@ -763,7 +763,7 @@ xSetHandleSize(Handle h, Size s)
*/
short
-getpath(short vRefNum, Str255 fileName, Str255 *ret, bool include_file)
+getpath(short vRefNum, Str255 fileName, Str255 ret, bool include_file)
{
WDPBRec wdir;
HVolumeParam wvol;
@@ -773,16 +773,16 @@ getpath(short vRefNum, Str255 fileName, Str255 *ret, b
char *tmpret = NULL, *tmp = NULL;
char *lastcolon;
- *ret[0] = 0;
+ ret[0] = 0;
if (strchr((char *)fileName + 1, ':') != NULL) {
/* already a full path */
- memcpy(*ret, fileName, 256);
+ memcpy(ret, fileName, 256);
if (!include_file) {
- PtoCstr(*ret);
- lastcolon = strrchr((char *)*ret, ':');
+ PtoCstr(ret);
+ lastcolon = strrchr((char *)ret, ':');
lastcolon[0] = '\0';
- CtoPstr(*ret);
+ CtoPstr(ret);
}
return 0;
}
@@ -864,7 +864,7 @@ getpath(short vRefNum, Str255 fileName, Str255 *ret, b
strlcat(tmpret, name, FILENAME_MAX);
}
} else if (retlen == 0) {
- (*ret)[0] = 0;
+ ret[0] = 0;
xfree(&tmp);
xfree(&tmpret);
xfree(&name);
@@ -872,7 +872,7 @@ getpath(short vRefNum, Str255 fileName, Str255 *ret, b
}
CtoPstr(tmpret);
- memcpy(*ret, tmpret, FILENAME_MAX);
+ memcpy(ret, tmpret, FILENAME_MAX);
xfree(&tmp);
xfree(&tmpret);
xfree(&name);
--- util.h Thu Mar 2 08:59:47 2023
+++ util.h Mon Mar 27 21:33:13 2023
@@ -124,7 +124,7 @@ char * xGetStringAsChar(short id);
bool xGetStringAsLong(short id, long *ret);
bool xSetHandleSize(Handle h, Size s);
-short getpath(short vRefNum, Str255 fileName, Str255 *ret, bool include_file);
+short getpath(short vRefNum, Str255 fileName, Str255 ret, bool include_file);
bool FIsDir(Str255 path);
short stat(char *path, struct stat *sb);
short FStat(Str255 path, struct stat *sb);