public Status SetConfig(ConfigProto config) { var bytes = config.ToByteArray(); var proto = Marshal.AllocHGlobal(bytes.Length); Marshal.Copy(bytes, 0, proto, bytes.Length); c_api.TF_SetConfig(_handle, proto, (ulong)bytes.Length, _status); _status.Check(false); return(_status); }
private unsafe void SetConfig(ConfigProto config) { var bytes = config.ToByteArray(); fixed(byte *proto2 = bytes) { using (var status = new Status()) { c_api.TF_SetConfig(Handle, (IntPtr)proto2, (ulong)bytes.Length, status.Handle); status.Check(false); } } }
public void SetConfig(ConfigProto config) { var bytes = config.ToByteArray(); //TODO! we can use WriteTo var proto = Marshal.AllocHGlobal(bytes.Length); //TODO! potential memory leak Marshal.Copy(bytes, 0, proto, bytes.Length); using (var status = new Status()) { c_api.TF_SetConfig(_handle, proto, (ulong)bytes.Length, status); status.Check(false); } Marshal.FreeHGlobal(proto); }
public void SetConfig(ConfigProto config) { var bytes = config.ToByteArray(); var proto = Marshal.AllocHGlobal(bytes.Length); Marshal.Copy(bytes, 0, proto, bytes.Length); using (var status = new Status()) { c_api.TF_SetConfig(_handle, proto, (ulong)bytes.Length, status); status.Check(false); } Marshal.FreeHGlobal(proto); }