Autor Beitrag
AeroX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Di 13.05.08 13:34 
hallo,
ich möchte gerne meine eigenen Methoden zum konvertieren machen,
aber ich krieg das mit den pointern nich richtig hin.

hier mal ein beispiel:

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
    private static unsafe void wstrcpy(char* dmem, char* smem, int charCount)
    {
        if (charCount > 0)
        {
            if ((((int)dmem) & 2) != 0)
            {
                dmem[0] = smem[0];
                dmem++;
                smem++;
                charCount--;
            }
            while (charCount >= 8)
            {
                *((int*)dmem) = *((uint*)smem);
                *((int*)(dmem + 2)) = *((uint*)(smem + 2));
                *((int*)(dmem + 4)) = *((uint*)(smem + 4));
                *((int*)(dmem + 6)) = *((uint*)(smem + 6));
                dmem += 8;
                smem += 8;
                charCount -= 8;
            }
            if ((charCount & 4) != 0)
            {
                *((int*)dmem) = *((uint*)smem);
                *((int*)(dmem + 2)) = *((uint*)(smem + 2));
                dmem += 4;
                smem += 4;
            }
            if ((charCount & 2) != 0)
            {
                *((int*)dmem) = *((uint*)smem);
                dmem += 2;
                smem += 2;
            }
            if ((charCount & 1) != 0)
            {
                dmem[0] = smem[0];
            }
        }
    }


das ist die methode wstrcpy aus der Klasse String.
Wenn ich sie mir kopiere, schreibt er dass uint nicht in int konvertiert werden kann!

was muss ich ändern?
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Fr 16.05.08 23:02 
Denke daran, dass du den Fx-Code nur als Referenz und nicht selbst benutzen oder verändern darfst. Und erst recht nicht hier posten :mrgreen: . [*]
Zum Problem: Ich sehe keinen Grund, warum du nicht einfach uint durch int ersetzen können solltest. Es geht ja nur um byteweises Kopieren mit ein wenig Loop Unrolling.

[edit]
[*] Auch Reflector- oder Rotor-Code ist natürlich nicht gerade FOSS.
[/edit]