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