projects
/
projects
/
chimara
/
chimara.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
83b722a
)
Avoid const string allocation/free
author
P. F. Chimento
<philip.chimento@gmail.com>
Sat, 18 Jun 2011 19:18:46 +0000
(21:18 +0200)
committer
P. F. Chimento
<philip.chimento@gmail.com>
Sat, 18 Jun 2011 20:09:56 +0000
(22:09 +0200)
libchimara/stream.c
patch
|
blob
|
history
diff --git
a/libchimara/stream.c
b/libchimara/stream.c
index b9d56cd03d4c055444a4198bfdfa067f7b3de7cd..0113b989edfe9245cbf66d025758e42f35141ca4 100644
(file)
--- a/
libchimara/stream.c
+++ b/
libchimara/stream.c
@@
-342,7
+342,7
@@
file_stream_new(frefid_t fileref, glui32 fmode, glui32 rock, gboolean unicode)
{
VALID_FILEREF(fileref, return NULL);
{
VALID_FILEREF(fileref, return NULL);
- gchar *modestr;
+
const
gchar *modestr;
/* Binary mode is 0x000, text mode 0x100 */
gboolean binary = !(fileref->usage & fileusage_TextMode);
switch(fmode)
/* Binary mode is 0x000, text mode 0x100 */
gboolean binary = !(fileref->usage & fileusage_TextMode);
switch(fmode)
@@
-352,10
+352,10
@@
file_stream_new(frefid_t fileref, glui32 fmode, glui32 rock, gboolean unicode)
ILLEGAL_PARAM("Tried to open a nonexistent file, '%s', in read mode", fileref->filename);
return NULL;
}
ILLEGAL_PARAM("Tried to open a nonexistent file, '%s', in read mode", fileref->filename);
return NULL;
}
- modestr =
g_strdup(binary? "rb" : "r")
;
+ modestr =
binary? "rb" : "r"
;
break;
case filemode_Write:
break;
case filemode_Write:
- modestr =
g_strdup(binary? "wb" : "w")
;
+ modestr =
binary? "wb" : "w"
;
break;
case filemode_WriteAppend:
case filemode_ReadWrite:
break;
case filemode_WriteAppend:
case filemode_ReadWrite:
@@
-367,7
+367,7
@@
file_stream_new(frefid_t fileref, glui32 fmode, glui32 rock, gboolean unicode)
IO_WARNING( "Error opening file", fileref->filename, g_strerror(errno) );
return NULL;
}
IO_WARNING( "Error opening file", fileref->filename, g_strerror(errno) );
return NULL;
}
- modestr =
g_strdup(binary? "r+b" : "r+")
;
+ modestr =
binary? "r+b" : "r+"
;
}
break;
default:
}
break;
default:
@@
-376,7
+376,6
@@
file_stream_new(frefid_t fileref, glui32 fmode, glui32 rock, gboolean unicode)
}
FILE *fp = g_fopen(fileref->filename, modestr);
}
FILE *fp = g_fopen(fileref->filename, modestr);
- g_free(modestr);
if(fp == NULL) {
IO_WARNING( "Error opening file", fileref->filename, g_strerror(errno) );
return NULL;
if(fp == NULL) {
IO_WARNING( "Error opening file", fileref->filename, g_strerror(errno) );
return NULL;