unsafe

error C4996: 'ctime': This function or variable may be unsafe

你说的曾经没有我的故事 提交于 2020-01-09 10:11:40
问题 I have a large project about static source code analysis, and everything compiles successfully, except for one thing. I have provided the error message in the title. The point that confuses me is that it gives an error message saying unsafe. I thought it should be just warning, not an error. By the way, I'm using Visual Studio 2012. Here is the part of the code where I get the error, in ctime. If someone can help me overcome this error, I would be glad. void CppCheckExecutor::reportProgress

error C4996: 'ctime': This function or variable may be unsafe

☆樱花仙子☆ 提交于 2020-01-09 10:11:30
问题 I have a large project about static source code analysis, and everything compiles successfully, except for one thing. I have provided the error message in the title. The point that confuses me is that it gives an error message saying unsafe. I thought it should be just warning, not an error. By the way, I'm using Visual Studio 2012. Here is the part of the code where I get the error, in ctime. If someone can help me overcome this error, I would be glad. void CppCheckExecutor::reportProgress

Why does returning a pointer with a method makes the test fail in debug mode?

二次信任 提交于 2020-01-05 02:25:30
问题 When I launch the following tests in Release mode, they both pass, but in Debug mode they both fail. [TestFixture] public unsafe class WrapperTests { [Test] public void should_correctly_set_the_size() { var wrapper = new Wrapper(); wrapper.q->size = 1; Assert.AreEqual(1, wrapper.rep()->size); // Expected 1 But was: 0 } [Test] public void should_correctly_set_the_refcount() { var wrapper = new Wrapper(); Assert.AreEqual(1, wrapper.rep()->refcount); // Expected 1 But was:508011008 } } public

C# unsafe code fixed pointer passed as parameter

泪湿孤枕 提交于 2020-01-03 08:37:33
问题 I came across the following code on msdn: unsafe static void SquarePtrParam (int* p) { *p *= *p; } unsafe static void Main() { Point pt = new Point(); pt.x = 5; pt.y = 6; // Pin pt in place: fixed (int* p = &pt.x) { SquarePtrParam (p); } // pt now unpinned. Console.WriteLine ("{0} {1}", pt.x, pt.y); } I am just wondering, we are directly accessing pointer in SquarePtrParam function, does it inherit information that array is fixed from calling method? Why don't we need to explicitly set it to

Perl Threads and Unsafe Signals

痴心易碎 提交于 2020-01-03 00:38:54
问题 So I recently wanted to thread one of my Perl programs to increase its speed. Taking in a list of websites, I wanted to start a thread for each url and get the content of each website and then look for a company description on the page. Once one thread found a result, or all thread's didn't, I wanted to exit, write my result, and read in urls for my next company. The problem that I see is that I use the Perl::Unsafe::Signals module inside of the function that I call when creating a thread. I

How does Marshal.GetFunctionPointerForDelegate work on instance members?

眉间皱痕 提交于 2020-01-01 11:59:07
问题 I am wondering about Marshal.GetFunctionPointerForDelegate. Namely I want to know how it converts a delegate to a function that is non static into a function pointer. Does it dynamically generate a code stub that has the instance attached somehow? And if so, doesn't this leak memory? Perhaps the delegate frees it in its finalizer? It doesn't look like System.Delegate has a finalizer, so I am very interested in how this mechanism works. I would assume that it would take 4 bytes for the

Faster (unsafe) BinaryReader in .NET

荒凉一梦 提交于 2019-12-31 09:02:11
问题 I came across a situation where I have a pretty big file that I need to read binary data from. Consequently, I realized that the default BinaryReader implementation in .NET is pretty slow. Upon looking at it with .NET Reflector I came across this: public virtual int ReadInt32() { if (this.m_isMemoryStream) { MemoryStream stream = this.m_stream as MemoryStream; return stream.InternalReadInt32(); } this.FillBuffer(4); return (((this.m_buffer[0] | (this.m_buffer[1] << 8)) | (this.m_buffer[2] <<

Faster (unsafe) BinaryReader in .NET

佐手、 提交于 2019-12-31 09:00:09
问题 I came across a situation where I have a pretty big file that I need to read binary data from. Consequently, I realized that the default BinaryReader implementation in .NET is pretty slow. Upon looking at it with .NET Reflector I came across this: public virtual int ReadInt32() { if (this.m_isMemoryStream) { MemoryStream stream = this.m_stream as MemoryStream; return stream.InternalReadInt32(); } this.FillBuffer(4); return (((this.m_buffer[0] | (this.m_buffer[1] << 8)) | (this.m_buffer[2] <<

Convert pointer to loop option in C#

て烟熏妆下的殇ゞ 提交于 2019-12-31 03:49:06
问题 How would I convert this into a loop and not to use the pointer. byte[] InputBuffer = new byte[8]; unsafe { fixed (byte* pInputBuffer = InputBuffer) { ((long*)pInputBuffer)[0] = value; } } I am trying to use the code from this page: query string parameter obfuscation 回答1: There's no looping here. You could use BitConverter.GetBytes instead of the unsafe type-punning cast. byte[] InputBuffer = BitConverter.GetBytes(value); replaces all six original lines of code. 来源: https://stackoverflow.com

Unsafe JavaScript attempt to access a frame when using secure browsing on Facebook

*爱你&永不变心* 提交于 2019-12-31 03:12:09
问题 I've launched an application last week and have noticed since that in Chrome only the height of my canvas is not always adjusted. I've spent a bunch of hours looking at the issues and noticed that I get the following error - sometimes. Unsafe JavaScript attempt to access frame with URL https://apps.facebook.com/tabletr/ from frame with URL http://static.ak.facebook.com/connect/canvas_proxy.php?version=3#behavior=p&method=getPageInfo&params=%7B%22channelUrl%22%3A%22https%3A%2F%2Fs-static.ak