+#ifdef __cplusplus
+extern "C" {
+#endif
// Basics
#include <stdlib.h>
// Memory management
-
- void *Malloc (int n)
-
+
+static void *Malloc (size_t n)
+
{ void *p;
if (n == 0) return NULL;
p = (void*) malloc (n);
}
return p;
}
-
- void Free (void *p)
-
- { if (p) free (p);
+
+static void Free (void *p)
+
+ { if (p) free (p);
}
-
- void *Realloc (void *p, int n)
-
+
+static void *Realloc (void *p, size_t n)
+
{ if (p == NULL) return Malloc (n);
if (n == 0) { Free(p); return NULL; }
p = (void*) realloc (p,n);
// bits needed to represent a number between 0 and n
-uint bits (uint n)
+uint _bits (uint n)
{ uint b = 0;
while (n)
// writes e[p..p+len-1] = s, len <= W
-void bitwrite (register uint *e, register uint p,
+void bitwrite (register uint *e, register uint p,
register uint len, register uint s)
{ e += p/W; p %= W;
}
// writes e[p..p+len-1] = 0
-void bitzero2 (register uint *e, register uint p,
+void bitzero2 (register uint *e, register uint p,
register uint len)
{ e += p/W; p %= W;
if (len > 0)
*e &= ~(((1<<len)-1)<<p);
}
+#ifdef __cplusplus
+}
+#endif