document pt_ctx as optional
authorTero Marttila <terom@fixme.fi>
Mon, 25 Jan 2010 02:09:29 +0200
changeset 64 98d934a9b3db
parent 63 2aab5d906dc8
child 65 e02bede4a6e4
document pt_ctx as optional
include/pngtile.h
src/lib/image.c
--- a/include/pngtile.h	Mon Jan 25 02:04:35 2010 +0200
+++ b/include/pngtile.h	Mon Jan 25 02:09:29 2010 +0200
@@ -122,8 +122,10 @@
 /**
  * Open a new pt_image for use.
  *
+ * The pt_ctx is optional, but required for pt_image_tile_async.
+ *
  * @param img_ptr returned pt_image handle
- * @param ctx global state to use
+ * @param ctx global state to use (optional)
  * @param path filesystem path to .png file
  * @param mode combination of PT_OPEN_* flags
  */
@@ -184,6 +186,8 @@
  *
  * This function may return before the PNG has been rendered.
  *
+ * Fails with PT_ERR if not pt_ctx was given to pt_image_open.
+ *
  * @param image render from image's cache. The cache must have been opened previously!
  * @param info tile parameters
  * @param out IO stream to write PNG data to, and close once done
@@ -199,7 +203,12 @@
  * Error codes returned
  */
 enum pt_error {
+    /** No error */
     PT_SUCCESS = 0,
+    
+    /** Generic error */
+    PT_ERR = 1,
+
     PT_ERR_MEM,
 
     PT_ERR_PATH,
--- a/src/lib/image.c	Mon Jan 25 02:04:35 2010 +0200
+++ b/src/lib/image.c	Mon Jan 25 02:09:29 2010 +0200
@@ -206,6 +206,9 @@
     return err;
 }
 
+/**
+ * Async work func for pt_image_tile_async
+ */
 static void _pt_image_tile_async (void *arg)
 {
     struct pt_tile *tile = arg;
@@ -228,6 +231,10 @@
     struct pt_tile *tile;
     int err;
 
+    // need a ctx for this
+    if (!image->ctx)
+        return -1;
+
     // alloc
     if ((err = pt_tile_new(&tile)))
         return err;