* added swfrender interface
[swftools.git] / lib / rfxswf.c
index 061010b..8513966 100644 (file)
 #include "./bitio.h"
 #include "./MD5.h"
 
+// memory allocation
+
+void* rfxalloc(int size)
+{
+  void*ptr;
+#ifdef HAVE_CALLOC
+  ptr = calloc(size);
+#else
+  ptr = malloc(size);
+  memset(ptr, 0, size);
+#endif
+  if(!ptr) {
+    fprintf(stderr, "FATAL: Out of memory\n");
+    /* TODO: we should send a signal, so that the debugger kicks in */
+    exit(1);
+  }
+  return ptr;
+}
+
+void rfxdealloc(void*ptr)
+{
+  free(ptr);
+}
+
 // internal constants
 
 #define MALLOC_SIZE     128
@@ -55,7 +79,6 @@
 
 #define MEMSIZE(l) (((l/MALLOC_SIZE)+1)*MALLOC_SIZE)
 
-
 // inline wrapper functions
 
 TAG * swf_NextTag(TAG * t) { return t->next; }