+
+ #region AllocateClear
+
+ private static bool IsUnix =
+ (int) Environment.OSVersion.Platform == 4 || (int) Environment.OSVersion.Platform == 128 || (int) Environment.OSVersion.Platform == 6;
+
+ [DllImport("libc")]
+ private static extern IntPtr calloc (int nmemb, int size);
+
+ private const int GMEM_ZEROINIT = 0x40;
+
+ [DllImport("kernel32")]
+ private static extern IntPtr GlobalAlloc (int flags, int bytes);
+
+ //http://download-uk.oracle.com/docs/cd/B14117_01/appdev.101/b10779/oci05bnd.htm#423147
+ internal static IntPtr AllocateClear (int cb)
+ {
+ if (IsUnix) {
+ return calloc (1, cb);
+ } else {
+ return GlobalAlloc (GMEM_ZEROINIT, cb);
+ }
+ }
+
+ #endregion AllocateClear