Skip to content
Snippets Groups Projects
Commit 9b2cc301 authored by rswindell's avatar rswindell
Browse files

Minor optimization of fnopen() - removed unnecessary calls to strcpy().

parent d0ebcb59
Branches
Tags
No related merge requests found
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -74,7 +74,7 @@ int nopen(const char* str, int access)
/****************************************************************************/
FILE* fnopen(int* fd, const char* str, int access)
{
char mode[128];
char* mode;
int file;
FILE * stream;
......@@ -86,19 +86,19 @@ FILE* fnopen(int* fd, const char* str, int access)
if(access&O_APPEND) {
if((access&O_RDWR)==O_RDWR)
strcpy(mode,"a+");
mode="a+";
else
strcpy(mode,"a");
mode="a";
} else if(access&(O_TRUNC|O_WRONLY)) {
if((access&O_RDWR)==O_RDWR)
strcpy(mode,"w+");
mode="w+";
else
strcpy(mode,"w");
mode="w";
} else {
if((access&O_RDWR)==O_RDWR)
strcpy(mode,"r+");
mode="r+";
else
strcpy(mode,"r");
mode="r";
}
stream=fdopen(file,mode);
if(stream==NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment