unsafe Questions

1

Solved

Does the line fixed (int* pArray = &array[0]) from the example below pin the whole array, or just array[0]? int array = new int[10]; unsafe { fixed (int* pArray = &array[0]) { } // or jus...
Waikiki asked 3/9, 2015 at 20:12

1

Solved

I tested the keyword fixed with array and string variables and worked really well but I can't use with a single variable. static void Main() { int value = 12345; unsafe { fixed (int* pValue = ...
Stickpin asked 3/9, 2015 at 20:4

1

Solved

I created a class library today with the new Class Library (Package) templates in Visual Studio 2015. Apparently it uses a fancy new project format, the ASP.NET xproj, for building the package. Whi...
Microwave asked 25/8, 2015 at 18:46

1

I have a small AngularJS app where I am trying to open an uploaded image and am running into the issue where angular adds "unsafe:" at the beginning of the URL. I have added the following lin...
Melodymeloid asked 17/2, 2015 at 23:24

2

Solved

An application I'm contributing to fires up a component written in C. The C process does some pretty heavy crunching and if your not careful can really hammer your CPU. Is there a way to set a li...
Susuable asked 20/3, 2012 at 19:11

2

Solved

Java 8 has added three fences to sun.misc.Unsafe. I feel confused after I read their documentation. So, I searched the web, and found this link. According to the page above, I believe these meth...
Boding asked 2/6, 2015 at 15:42

3

I found that my application spends 25% of its time doing this in a loop: private static int Diff (int c0, int c1) { unsafe { byte* pc0 = (byte*) &c0; byte* pc1 = (byte*) &c1; int d0 = ...
Nanna asked 2/5, 2015 at 22:30

3

Solved

I am currently reading the ECMA-334 as suggested by a friend that does programming for a living. I am on the section dealing with Unsafe code. Although, I am a bit confused by what they are talking...
Abstraction asked 5/5, 2015 at 23:15

4

Solved

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 ...
Bitterweed asked 6/2, 2012 at 21:15

1

Solved

I'm trying to convert an uint32 to a byte array (4 bytes) in Go using the unsafe library: h := (uint32)(((fh.year*100+fh.month)*100+fh.day)*100 + fh.h) a := make([]byte, unsafe.Sizeof(h)) copy(a, ...
Wahl asked 15/3, 2015 at 14:30

3

Solved

I got this error when building a sample visual C++ project. First I downloaded 3 sample projects, all solve the same problem, print out all the prime numbers less than N (you may know these sample ...
Auxesis asked 5/2, 2013 at 15:6

2

Solved

I've been trying to determine what the true cost of using the fixed statement within C# for managed unsafe structs that contain fixed arrays. Please note I am not referring to unmanaged structs. Sp...
Aubrey asked 13/12, 2011 at 22:18

1

Solved

I have some code that, when simplified, looks like: fn foo() -> Vec<u8> { unsafe { unsafe_iterator().map(|n| wrap_element(n)).collect() } } The iterator returns items that would be i...
Annitaanniversary asked 2/1, 2015 at 18:19

1

I am working on a cross platform application that targets Android and iOS platforms. I am using jQuery 1.9.1, Jquery Mobile 1.3.1 and Phonegap 2.8.0. I want to send an ajax request and set the re...
Scrawl asked 18/3, 2014 at 14:11

1

Solved

Can I somehow get an array from std::ptr::read? I'd like to do something close to: let mut v: Vec<u8> = ... let view = &some_struct as *const _ as *const u8; v.write(&std::ptr::read...
Chloris asked 26/11, 2014 at 13:37

2

Solved

Does anyone know of any comprehensive documentation for sun.misc.Unsafe? I'm looking for documentation on Unsafe.putOrderedInt(). This was all I was able to find. public native void putO...
Fornax asked 29/5, 2013 at 16:24

4

Solved

I want to premise that this question's purpose is checking if there's at least one way, even if through the most unsafe hack, to keep a reference to a non-blittable value type. I am aware that such...
Palmette asked 5/1, 2013 at 2:37

3

Solved

If one tries to make a generic struct with the [StructLayout(LayoutKind.Explicit)] attribute, using the struct generates an exception at runtime: System.TypeLoadException: Could not load type 'f...
Deluca asked 4/11, 2014 at 22:22

2

Solved

I need to use SecureString for a Microsoft's class and i found the following code on the internet: public static class SecureStringExt { public static SecureString ConvertToSecureString(this stri...
Unstudied asked 20/9, 2014 at 22:26

1

Solved

I have the following code: class Program { private unsafe static void SquarePtrParam(int* input) { *input *= *input; } private static void SquareRefParam(ref int input) { input *= input; ...
Missymist asked 21/3, 2014 at 0:56

2

Solved

I need to call unsafe method that takes raw pointers. For that I need to construct Expression that represents pointer to value represented by VariableExpression or ParameterExpression. How to d...
Ludewig asked 18/3, 2014 at 12:25

1

Solved

When running this code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace StructLayoutTest { class Program { ...
Stalemate asked 2/5, 2013 at 8:28

1

Solved

I just wanted to add an image to my app. As advised, I used the ng-src directive: <img ng-src="{{app.imgBig}}" alt="lorem ipsum" height="100" width="200" title="lorem ipsum" /> It works f...
Invocation asked 17/2, 2014 at 19:38

5

Solved

I know C# gives the programmer the ability to access, use pointers in an unsafe context. But When is this needed? At what circumstances, using pointers becomes inevitable? Is it only for performa...
Snuffbox asked 2/3, 2011 at 18:32

3

Solved

I would like to know the VB.NET equivalent of the following C# code: unsafe { byte* pStart = (byte*)(void*)writeableBitmap.BackBuffer; int nL = writeableBitmap.BackBufferStride; for (int r =...
Heartbreaking asked 6/5, 2011 at 19:1

© 2022 - 2024 — McMap. All rights reserved.