~vcs-imports/openmapi/git-trunk

« back to all changes in this revision

Viewing changes to providers/NMapi.Provider.Styx/Interop/Transmogrify.cs

  • Committer: Michael Kukat
  • Date: 2010-05-06 15:04:53 UTC
  • Revision ID: git-v1:56f7fe7aab428e178a1f63b33caf4e9e785204e6
fixed bug (field in native structure missing)

Show diffs side-by-side

added added

removed removed

Lines of Context:
942
942
                return IntPtr.Zero;
943
943
            }
944
944
 
945
 
            IntPtr RealArray = MemCtx.Alloc<uint> (list.AEntries.Length + 1);
 
945
            /* XXX not nice, but rare */
 
946
            IntPtr RealArray = MemCtx.Alloc<byte> (Marshal.SizeOf(typeof(NativeSizedArray)) * list.AEntries.Length + Marshal.SizeOf(typeof(uint)));
946
947
 
947
948
            Marshal.WriteInt32 (RealArray, list.AEntries.Length);
948
949
            IntPtr iter = (IntPtr) ((int) RealArray + Marshal.SizeOf (typeof (UInt32)));
949
950
 
950
951
            foreach (AdrEntry entry in list.AEntries) {
951
 
                NativeSizedArray Array = new NativeSizedArray ();
952
 
                Array.Data = PropArrayToPtr (entry.PropVals, out Array.Count, MemCtx);
953
 
                Marshal.StructureToPtr (Array, iter, false);
954
 
                iter = (IntPtr) ((int) iter + Marshal.SizeOf (Array));
 
952
                /* XXX this shouldn't happen, but we are still having ONC-RPC */
 
953
                if(entry != null && entry.PropVals != null) {
 
954
                    NativeSizedArray Array = new NativeSizedArray ();
 
955
                    Array.Data = PropArrayToPtr (entry.PropVals, out Array.Count, MemCtx);
 
956
                    Marshal.WriteInt32 (iter, 0);
 
957
                    iter = (IntPtr) ((int) iter + Marshal.SizeOf (typeof (UInt32)));
 
958
                    Marshal.StructureToPtr (Array, iter, false);
 
959
                    iter = (IntPtr) ((int) iter + Marshal.SizeOf (Array));
 
960
                } else {
 
961
                    System.Console.WriteLine("WARNING: AdrListToPointer() AdrList with broken entries");
 
962
                    return IntPtr.Zero;
 
963
                }
955
964
            }
956
965
 
957
966
            return RealArray;