[xiph-commits] r3820 - in liboggz/trunk: include/oggz src/liboggz

conrad at svn.annodex.net conrad at svn.annodex.net
Sun Dec 7 21:56:46 PST 2008


Author: conrad
Date: 2008-12-07 21:56:45 -0800 (Sun, 07 Dec 2008)
New Revision: 3820

Modified:
   liboggz/trunk/include/oggz/oggz_io.h
   liboggz/trunk/src/liboggz/oggz_io.c
Log:
liboggz::oggz_io: handle out of memory (& update API docs)


Modified: liboggz/trunk/include/oggz/oggz_io.h
===================================================================
--- liboggz/trunk/include/oggz/oggz_io.h	2008-12-08 05:36:16 UTC (rev 3819)
+++ liboggz/trunk/include/oggz/oggz_io.h	2008-12-08 05:56:45 UTC (rev 3820)
@@ -125,6 +125,7 @@
  * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ; \a oggz not
  * open for reading.
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  */
 int oggz_io_set_read (OGGZ * oggz, OggzIORead read, void * user_handle);
 
@@ -147,6 +148,7 @@
  * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ; \a oggz not
  * open for writing.
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  */
 int oggz_io_set_write (OGGZ * oggz, OggzIOWrite write, void * user_handle);
 
@@ -168,6 +170,7 @@
  * \retval 0 Success
  * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  *
  * \note If you provide an OggzIOSeek function, you MUST also provide
  * an OggzIOTell function, or else all your seeks will fail.
@@ -193,6 +196,7 @@
  * \retval 0 Success
  * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  */
 int oggz_io_set_tell (OGGZ * oggz, OggzIOTell tell, void * user_handle);
 
@@ -216,6 +220,7 @@
  * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ; \a oggz not
  * open for writing.
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  */
 int oggz_io_set_flush (OGGZ * oggz, OggzIOFlush flush, void * user_handle);
 

Modified: liboggz/trunk/src/liboggz/oggz_io.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_io.c	2008-12-08 05:36:16 UTC (rev 3819)
+++ liboggz/trunk/src/liboggz/oggz_io.c	2008-12-08 05:56:45 UTC (rev 3820)
@@ -176,11 +176,15 @@
 
 /* get/set functions */
 
-static void
+static int
 oggz_io_init (OGGZ * oggz)
 {
   oggz->io = (OggzIO *) oggz_malloc (sizeof (OggzIO));
+  if (oggz->io == NULL) return -1;
+
   memset (oggz->io, 0, sizeof (OggzIO));
+
+  return 0;
 }
 
 int
@@ -189,7 +193,10 @@
   if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
   if (oggz->file != NULL) return OGGZ_ERR_INVALID;
 
-  if (oggz->io == NULL) oggz_io_init (oggz);
+  if (oggz->io == NULL) {
+    if (oggz_io_init (oggz) == -1)
+      return OGGZ_ERR_OUT_OF_MEMORY;
+  }
 
   oggz->io->read = read;
   oggz->io->read_user_handle = user_handle;
@@ -214,7 +221,10 @@
   if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
   if (oggz->file != NULL) return OGGZ_ERR_INVALID;
 
-  if (oggz->io == NULL) oggz_io_init (oggz);
+  if (oggz->io == NULL) {
+    if (oggz_io_init (oggz) == -1)
+      return OGGZ_ERR_OUT_OF_MEMORY;
+  }
 
   oggz->io->write = write;
   oggz->io->write_user_handle = user_handle;
@@ -239,7 +249,10 @@
   if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
   if (oggz->file != NULL) return OGGZ_ERR_INVALID;
 
-  if (oggz->io == NULL) oggz_io_init (oggz);
+  if (oggz->io == NULL) {
+    if (oggz_io_init (oggz) == -1)
+      return OGGZ_ERR_OUT_OF_MEMORY;
+  }
 
   oggz->io->seek = seek;
   oggz->io->seek_user_handle = user_handle;
@@ -264,7 +277,10 @@
   if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
   if (oggz->file != NULL) return OGGZ_ERR_INVALID;
 
-  if (oggz->io == NULL) oggz_io_init (oggz);
+  if (oggz->io == NULL) {
+    if (oggz_io_init (oggz) == -1)
+      return OGGZ_ERR_OUT_OF_MEMORY;
+  }
 
   oggz->io->tell = tell;
   oggz->io->tell_user_handle = user_handle;
@@ -289,7 +305,10 @@
   if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
   if (oggz->file != NULL) return OGGZ_ERR_INVALID;
 
-  if (oggz->io == NULL) oggz_io_init (oggz);
+  if (oggz->io == NULL) {
+    if (oggz_io_init (oggz) == -1)
+      return OGGZ_ERR_OUT_OF_MEMORY;
+  }
 
   oggz->io->flush = flush;
   oggz->io->flush_user_handle = user_handle;



More information about the commits mailing list