Mercurial > audlegacy-plugins
comparison src/stdio/stdio.c @ 2940:30d30cfe6b47
Handle file == NULL in ungetc().
| author | Matti Hamalainen <ccr@tnsp.org> |
|---|---|
| date | Mon, 22 Sep 2008 06:40:40 +0300 |
| parents | bd3a24b39058 |
| children | 3134a0987162 |
comparison
equal
deleted
inserted
replaced
| 2939:3877a02782bb | 2940:30d30cfe6b47 |
|---|---|
| 75 { | 75 { |
| 76 VFSFile *file; | 76 VFSFile *file; |
| 77 gchar *decpath; | 77 gchar *decpath; |
| 78 | 78 |
| 79 if (!path || !mode) | 79 if (!path || !mode) |
| 80 return NULL; | 80 return NULL; |
| 81 | 81 |
| 82 decpath = aud_vfs_stdio_urldecode_path(path); | 82 decpath = aud_vfs_stdio_urldecode_path(path); |
| 83 | 83 |
| 84 file = g_new(VFSFile, 1); | 84 file = g_new(VFSFile, 1); |
| 85 | 85 |
| 86 file->handle = fopen(decpath != NULL ? decpath : path, mode); | 86 file->handle = fopen(decpath != NULL ? decpath : path, mode); |
| 87 | 87 |
| 88 if (decpath != NULL) | 88 g_free(decpath); |
| 89 g_free(decpath); | |
| 90 | 89 |
| 91 if (file->handle == NULL) { | 90 if (file->handle == NULL) { |
| 92 g_free(file); | 91 g_free(file); |
| 93 file = NULL; | 92 file = NULL; |
| 94 } | 93 } |
| 155 | 154 |
| 156 return getc( handle ); | 155 return getc( handle ); |
| 157 } | 156 } |
| 158 | 157 |
| 159 gint | 158 gint |
| 160 stdio_aud_vfs_ungetc_impl(gint c, VFSFile *stream) | 159 stdio_aud_vfs_ungetc_impl(gint c, VFSFile * file) |
| 161 { | 160 { |
| 162 FILE *handle = (FILE *) stream->handle; | 161 FILE *handle; |
| 163 | 162 |
| 164 return ungetc( c , handle ); | 163 if (file == NULL) |
| 164 return -1; | |
| 165 | |
| 166 handle = (FILE *) file->handle; | |
| 167 | |
| 168 return ungetc(c, handle); | |
| 165 } | 169 } |
| 166 | 170 |
| 167 gint | 171 gint |
| 168 stdio_aud_vfs_fseek_impl(VFSFile * file, | 172 stdio_aud_vfs_fseek_impl(VFSFile * file, |
| 169 glong offset, | 173 glong offset, |
| 240 if (file == NULL) | 244 if (file == NULL) |
| 241 return -1; | 245 return -1; |
| 242 | 246 |
| 243 handle = (FILE *) file->handle; | 247 handle = (FILE *) file->handle; |
| 244 | 248 |
| 245 if (-1 == fstat(fileno(handle), &s)) | 249 if (fstat(fileno(handle), &s) == -1) |
| 246 return -1; | 250 return -1; |
| 247 | 251 |
| 248 return s.st_size; | 252 return s.st_size; |
| 249 } | 253 } |
| 250 | 254 |
