Reference the license from LGPL files (for Debian).
[ocaml-libvirt.git] / libvirt / generator.pl
index 4fbace6..cb4f12b 100755 (executable)
@@ -14,9 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 #
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+# Please see the file ../COPYING.LIB.
 
 # This generates libvirt_c.c (the core of the bindings).  You don't
 # need to run this program unless you are extending the bindings
@@ -233,9 +231,7 @@ print F <<'END';
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ * Please see the file ../COPYING.LIB.
  */
 
 #include "config.h"
@@ -620,6 +616,16 @@ sub gen_c_code
   int i = Int_val (iv);
   int ids[i], r;
 
+  /* Some libvirt List* functions still throw exceptions if i == 0,
+   * so catch that and return an empty array directly.  This changes
+   * the semantics slightly (masking other failures) but it's
+   * unlikely anyone will care.  RWMJ 2008/06/10
+   */
+  if (i == 0) {
+    rv = caml_alloc (0, 0);
+    CAMLreturn (rv);
+  }
+
   NONBLOCKING (r = $c_name (conn, ids, i));
   CHECK_ERROR (r == -1, conn, \"$c_name\");
 
@@ -637,6 +643,16 @@ sub gen_c_code
   char *names[i];
   int r;
 
+  /* Some libvirt List* functions still throw exceptions if i == 0,
+   * so catch that and return an empty array directly.  This changes
+   * the semantics slightly (masking other failures) but it's
+   * unlikely anyone will care.  RWMJ 2008/06/10
+   */
+  if (i == 0) {
+    rv = caml_alloc (0, 0);
+    CAMLreturn (rv);
+  }
+
   NONBLOCKING (r = $c_name ($1, names, i));
   CHECK_ERROR (r == -1, conn, \"$c_name\");