summaryrefslogtreecommitdiff
path: root/src/cairo-output-stream.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-01-05 21:20:45 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-01-05 21:25:30 +0000
commitf440d894e668994721248dc6c95a936a839870db (patch)
tree5d9d3e1180a1c05d77028716a9a4cbbb33accbea /src/cairo-output-stream.c
parent68a441e582c6c887e65800302906ddd35cb0291e (diff)
Check errno for appropriate error return.
After using fopen() and friends check the global errno to determine the most appropriate error return - especially important when running memfault, where correct reporting of NO_MEMORY errors is required.
Diffstat (limited to 'src/cairo-output-stream.c')
-rw-r--r--src/cairo-output-stream.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index b8fb706b..6451b0fe 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -38,8 +38,10 @@
#include "cairo-output-stream-private.h"
+#include <stdio.h>
#include <locale.h>
#include <ctype.h>
+#include <errno.h>
#ifdef _MSC_VER
#define snprintf _snprintf
@@ -538,8 +540,14 @@ _cairo_output_stream_create_for_filename (const char *filename)
file = fopen (filename, "wb");
if (file == NULL) {
- _cairo_error_throw (CAIRO_STATUS_WRITE_ERROR);
- return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
+ switch (errno) {
+ case ENOMEM:
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+ return (cairo_output_stream_t *) &_cairo_output_stream_nil;
+ default:
+ _cairo_error_throw (CAIRO_STATUS_WRITE_ERROR);
+ return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
+ }
}
stream = malloc (sizeof *stream);