Skip to content

Latest commit

 

History

History
 
 

DiscordGameSDK

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Discord Game SDK code

This directory contains the C# code distributed in version 3.2.1 of the Discord Game SDK.

The SDK was altered to fix a garbage collection issue that causes segfaults on Windows, by changing all the callbacks that way:

+       private static FFIMethods.ValidateOrExitCallback validateOrExitCallback = ValidateOrExitCallbackImpl;
        [MonoPInvokeCallback]
        private static void ValidateOrExitCallbackImpl(IntPtr ptr, Result result)
        {
            GCHandle h = GCHandle.FromIntPtr(ptr);
            ValidateOrExitHandler callback = (ValidateOrExitHandler)h.Target;
            h.Free();
            callback(result);
        }

        public void ValidateOrExit(ValidateOrExitHandler callback)
        {
            GCHandle wrapped = GCHandle.Alloc(callback);
-           Methods.ValidateOrExit(MethodsPtr, GCHandle.ToIntPtr(wrapped), ValidateOrExitCallbackImpl);
+           Methods.ValidateOrExit(MethodsPtr, GCHandle.ToIntPtr(wrapped), validateOrExitCallback);
        }