it CompilerhelperForInitializingFinalizingVariable;

 interface

 { Compiler helper for initializing/finalizing variable }

 procedure _Initialize(p : Pointer; typeInfo : Pointer);
procedure _InitializeArray(p : Pointer; typeInfo : Pointer; elemCount : NativeUInt);
procedure _InitializeRecord(p : Pointer; typeInfo : Pointer); {$IF not defined(X86ASMRTL)}
// dcc64 generated code expects P to remain in RAX on exit from this function.
function _Finalize(P : Pointer; TypeInfo : Pointer): Pointer;
function _FinalizeArray(P : Pointer; TypeInfo : Pointer; ElemCount : NativeUInt): Pointer;
function _FinalizeRecord(P : Pointer; TypeInfo : Pointer): Pointer;
{$ELSE}
procedure _Finalize(p : Pointer; typeInfo : Pointer);
procedure _FinalizeArray(P : Pointer; TypeInfo : Pointer; ElemCount : NativeUInt);
procedure _FinalizeRecord(P : Pointer; TypeInfo : Pointer);
{$ENDIF} procedure _CopyRecord(Dest, Source, TypeInfo : Pointer);
procedure _CopyObject(Dest, Source : Pointer; vmtPtrOffs : NativeInt; TypeInfo : Pointer);
procedure _CopyArray(Dest, Source, TypeInfo : Pointer; Count : NativeUInt); procedure _AddRef(P : Pointer; TypeInfo : Pointer);
procedure _AddRefArray(P : Pointer; TypeInfo : Pointer; ElemCount : NativeUInt);
procedure _AddRefRecord(P : Pointer; TypeInfo : Pointer); function _New(Size : NativeInt; TypeInfo : Pointer): Pointer;
procedure _Dispose(P : Pointer; TypeInfo : Pointer); procedure InitializeArray(p : Pointer; typeInfo : Pointer; elemCount : NativeUInt);
procedure CopyArray(Dest, Source, TypeInfo : Pointer; Count : NativeInt);
procedure FinalizeArray(P : Pointer; TypeInfo : Pointer; Count : NativeUInt); implementation { ===========================================================================
InitializeRecord, InitializeArray, and Initialize are PIC safe even though
they alter EBX because they only call each other. They never call out to
other functions and they don t access global data. FinalizeRecord, Finalize, and FinalizeArray are PIC safe because they call
Pascal routines which will have EBX fixup prologs.
===========================================================================}
procedure _VarClr(var v : TVarData);
begin
if Assigned(VarClearProc) then
VarClearProc(v)
else
Error(reVarInvalidOp);
end; procedure _VarCopy(var Dest : TVarData; const Src : TVarData);
begin
if Assigned(VarCopyProc) then
VarCopyProc(Dest, Src)
else
Error(reVarInvalidOp);
end; procedure _VarAddRef(var v : TVarData);
begin
if Assigned(VarAddRefProc) then
VarAddRefProc(v)
else
Error(reVarInvalidOp);
end; { ===========================================================================
InitializeRecord, InitializeArray, and Initialize are PIC safe even though
they alter EBX because they only call each other. They never call out to
other functions and they don t access global data. FinalizeRecord, Finalize, and FinalizeArray are PIC safe because they call
Pascal routines which will have EBX fixup prologs.
===========================================================================} procedure _InitializeRecord(p : Pointer; typeInfo : Pointer);
var
FT : PFieldTable;
I : Cardinal;
begin
FT := PFieldTable(PByte(typeInfo) + Byte(PTypeInfo(typeInfo).Name[]));
if FT.Count > then
begin
for I := FT.Count - downto do
{$IFDEF WEAKREF}
if FT.Fields[I].TypeInfo <> nil then
{$ENDIF}
_InitializeArray(Pointer(PByte(P) + UIntPtr(FT.Fields[I].Offset)),
FT.Fields[I].TypeInfo^, );
end;
end; function _FinalizeRecord(P : Pointer; TypeInfo : Pointer): Pointer;
var
FT : PFieldTable;
I : Cardinal;
{$IFDEF WEAKREF}
Weak : Boolean;
{$ENDIF}
begin
FT := PFieldTable(PByte(TypeInfo) + Byte(PTypeInfo(TypeInfo).Name[]));
if FT.Count > then
begin
{$IFDEF WEAKREF}
Weak := false;
{$ENDIF}
for I := to FT.Count - do
begin
{$IFDEF WEAKREF}
if FT.Fields[I].TypeInfo = nil then
begin
Weak := true;
Continue;
end;
if not Weak then
begin
{$ENDIF}
_FinalizeArray(Pointer(PByte(P) + IntPtr(FT.Fields[I].Offset)),
FT.Fields[I].TypeInfo^, );
{$IFDEF WEAKREF}
end
else
begin
case FT.Fields[I].TypeInfo^.Kind of
{$IFDEF WEAKINTFREF}
tkInterface:
_IntfWeakClear(IInterface(Pointer(PByte(P) +
IntPtr(FT.Fields[I].Offset))^));
{$ENDIF}
{$IFDEF WEAKINSTREF}
tkClass:
_InstWeakClear(TObject(Pointer(PByte(P) + IntPtr(FT.Fields[I].Offset))^));
{$ENDIF}
{$IFDEF WEAKREF}
tkMethod:
_ClosureRemoveWeakRef(TMethod(Pointer(PByte(P) +
IntPtr(FT.Fields[I].Offset))^));
{$ENDIF}
else
Error(reInvalidPtr);
end;
end;
{$ENDIF}
end;
end;
Result := P;
end; procedure _InitializeArray(p : Pointer; typeInfo : Pointer; elemCount : NativeUInt);
var
FT : PFieldTable;
I : Cardinal;
begin
if elemCount = then
Exit;
case PTypeInfo(typeInfo).Kind of
{$IFDEF WEAKREF}
tkMethod:
while elemCount > do
begin
TMethod(P^).Data := nil;
TMethod(P^).Code := nil;
Inc(PByte(P), SizeOf(TMethod));
Dec(elemCount);
end;
{$ENDIF}
{$IFDEF AUTOREFCOUNT}
tkClass,
{$ENDIF}
tkLString, tkWString, tkInterface, tkDynArray, tkUString:
while elemCount > do
begin
PPointer(P)^ := nil;
Inc(PByte(P), SizeOf(Pointer));
Dec(elemCount);
end;
tkVariant:
while elemCount > do
begin
with PVarData(P)^ do
for I := Low(RawData) to High(RawData) do
RawData[I] := ;
Inc(PByte(P), SizeOf(TVarData));
Dec(elemCount);
end;
tkArray:
begin
FT := PFieldTable(PByte(typeInfo) + Byte(PTypeInfo(typeInfo).Name[]));
while elemCount > do
begin
_InitializeArray(P, FT.Fields[].TypeInfo^, FT.Count);
Inc(PByte(P), FT.Size);
Dec(elemCount);
end;
end;
tkRecord:
begin
FT := PFieldTable(PByte(typeInfo) + Byte(PTypeInfo(typeInfo).Name[]));
while elemCount > do
begin
_InitializeRecord(P, typeInfo);
Inc(PByte(P), FT.Size);
Dec(elemCount);
end;
end;
else
Error(reInvalidPtr);
end;
end; function _FinalizeArray(P : Pointer; TypeInfo : Pointer; ElemCount : NativeUInt): Pointer;
var
FT : PFieldTable;
begin
Result := P;
if ElemCount = then
Exit;
case PTypeInfo(TypeInfo).Kind of
{$IFDEF WEAKREF}
tkMethod:
while ElemCount > do
begin
_ClosureRemoveWeakRef(TMethod(P^));
Inc(PByte(P), SizeOf(TMethod));
Dec(ElemCount);
end;
{$ENDIF}
{$IFDEF AUTOREFCOUNT}
tkClass:
while ElemCount > do
begin
_InstClear(TObject(P^));
Inc(PByte(P), SizeOf(Pointer));
Dec(ElemCount);
end;
{$ENDIF}
tkLString:
_LStrArrayClr(P^, ElemCount);
tkWString:
_WStrArrayClr(P^, ElemCount);
tkUString:
_UStrArrayClr(P^, ElemCount);
tkVariant:
while ElemCount > do
begin
_VarClr(PVarData(P)^);
Inc(PByte(P), SizeOf(TVarData));
Dec(ElemCount);
end;
tkArray:
begin
FT := PFieldTable(PByte(typeInfo) + Byte(PTypeInfo(typeInfo).Name[]));
while ElemCount > do
begin
_FinalizeArray(P, FT.Fields[].TypeInfo^, FT.Count);
Inc(PByte(P), FT.Size);
Dec(ElemCount);
end;
end;
tkRecord:
begin
FT := PFieldTable(PByte(TypeInfo) + Byte(PTypeInfo(TypeInfo).Name[]));
while ElemCount > do
begin
_FinalizeRecord(P, TypeInfo);
Inc(PByte(P), FT.Size);
Dec(ElemCount);
end;
end;
tkInterface:
while ElemCount > do
begin
_IntfClear(IInterface(P^));
Inc(PByte(P), SizeOf(Pointer));
Dec(ElemCount);
end;
tkDynArray:
while ElemCount > do
begin
{ The cast and dereference of P here is to fake out the call to
_DynArrayClear. That function expects a var parameter. Our
declaration says we got a non-var parameter, but because of
the data type that got passed to us (tkDynArray), this isn t
strictly true. The compiler will have passed us a reference. }
_DynArrayClear(PPointer(P)^, typeInfo);
Inc(PByte(P), SizeOf(Pointer));
Dec(ElemCount);
end;
else
Error(reInvalidPtr);
end;
end; procedure _AddRefRecord(P : Pointer; TypeInfo : Pointer);
var
FT : PFieldTable;
I : Cardinal;
begin
FT := PFieldTable(PByte(TypeInfo) + Byte(PTypeInfo(TypeInfo).Name[]));
if FT.Count > then
begin
for I := to FT.Count - do
begin
{$IFDEF WEAKREF}
// Check for the sentinal indicating the following fields are weak references
// which don t need to be reference counted
if FT.Fields[I].TypeInfo = nil then
Break;
{$ENDIF}
_AddRefArray(Pointer(PByte(P) + UIntPtr(FT.Fields[I].Offset)),
FT.Fields[I].TypeInfo^, );
end;
end;
end; procedure _AddRefArray(P : Pointer; TypeInfo : Pointer; ElemCount : NativeUInt);
var
FT : PFieldTable;
begin
if ElemCount = then
Exit;
case PTypeInfo(TypeInfo).Kind of
{$IFDEF WEAKREF}
tkMethod:
while ElemCount > do
begin
_ClosureAddWeakRef(TMethod(P^));
Inc(PByte(P), SizeOf(TMethod));
Dec(ElemCount);
end;
{$ENDIF}
{$IFDEF AUTOREFCOUNT}
tkClass:
while ElemCount > do
begin
_InstAddRef(TObject(P^));
Inc(PByte(P), SizeOf(Pointer));
Dec(ElemCount);
end;
{$ENDIF}
tkLString:
while ElemCount > do
begin
_LStrAddRef(PPointer(P)^);
Inc(PByte(P), SizeOf(Pointer));
Dec(ElemCount);
end;
tkWString:
while ElemCount > do
begin
{$IFDEF MSWINDOWS}
_WStrAddRef(PWideString(P)^);
{$ELSE}
_WStrAddRef(PPointer(P)^);
{$ENDIF}
Inc(PByte(P), SizeOf(Pointer));
Dec(ElemCount);
end;
tkUString:
while ElemCount > do
begin
_UStrAddRef(PPointer(P)^);
Inc(PByte(P), SizeOf(Pointer));
Dec(ElemCount);
end;
tkVariant:
while ElemCount > do
begin
_VarAddRef(PVarData(P)^);
Inc(PByte(P), SizeOf(TVarData));
Dec(ElemCount);
end;
tkArray:
begin
FT := PFieldTable(PByte(TypeInfo) + Byte(PTypeInfo(TypeInfo).Name[]));
while ElemCount > do
begin
_AddRefArray(P, FT.Fields[].TypeInfo^, FT.Count);
Inc(PByte(P), FT.Size);
Dec(ElemCount);
end;
end;
tkRecord:
begin
FT := PFieldTable(PByte(TypeInfo) + Byte(PTypeInfo(TypeInfo).Name[]));
while ElemCount > do
begin
_AddRefRecord(P, TypeInfo);
Inc(PByte(P), FT.Size);
Dec(ElemCount);
end;
end;
tkInterface:
while ElemCount > do
begin
_IntfAddRef(IInterface(P^));
Inc(PByte(P), SizeOf(Pointer));
Dec(ElemCount);
end;
tkDynArray:
while ElemCount > do
begin
_DynArrayAddRef(PPointer(P)^);
Inc(PByte(P), SizeOf(Pointer));
Dec(ElemCount);
end;
else
Error(reInvalidPtr);
end;
end; procedure _AddRef(P : Pointer; TypeInfo : Pointer);
begin
_AddRefArray(P, TypeInfo, );
end; procedure _CopyRecord(Dest, Source, TypeInfo : Pointer);
var
FT, EFT : PFieldTable;
I, Count, L : Cardinal;
{$IFDEF WEAKREF}
J, K : Cardinal;
{$ENDIF}
Offset : UIntPtr;
FTypeInfo : PTypeInfo;
DestOff, SrcOff : Pointer;
begin
FT := PFieldTable(PByte(TypeInfo) + Byte(PTypeInfo(TypeInfo).Name[]));
Offset := ;
if FT.Count > then
begin
Count := FT.Count;
{$IFDEF WEAKREF}
J := ;
K := Count;
for I := Count - downto do
if FT.Fields[I].TypeInfo = nil then
begin
K := I + ; // found the weak sentinal
Dec(Count); // remove the sentinal from consideration
Break;
end;
{$ENDIF}
for L := to Count - do
begin
{$IFDEF WEAKREF}
if (FT.Fields[J].TypeInfo <> nil) and
((K = FT.Count) or (FT.Fields[J].Offset < FT.Fields[K].Offset)) then
begin
I := J;
Inc(J);
end
else
begin
I := K;
Inc(K);
end;
{$ELSE}
I := L;
{$ENDIF}
if FT.Fields[I].Offset > Offset then
Move(Pointer(PByte(Source) + Offset)^,
Pointer(PByte(Dest) + Offset)^,
FT.Fields[I].Offset - Offset);
Offset := FT.Fields[I].Offset;
FTypeInfo := FT.Fields[I].TypeInfo^;
DestOff := Pointer(PByte(Dest) + Offset);
SrcOff := Pointer(PByte(Source) + Offset);
case FTypeInfo.Kind of
{$IFDEF WEAKREF}
tkMethod:
begin
_CopyClosure(PMethod(DestOff)^, PMethod(SrcOff)^);
Inc(Offset, SizeOf(TMethod));
end;
{$ENDIF}
{$IFDEF AUTOREFCOUNT}
tkClass:
begin
{$IFDEF WEAKINSTREF}
if I > J then
_InstWeakCopy(TObject(PPointer(DestOff)^),
TObject(PPointer(SrcOff)^))
else
{$ENDIF}
_InstCopy(TObject(PPointer(DestOff)^), TObject(PPointer(SrcOff)^));
Inc(Offset, SizeOf(Pointer));
end;
{$ENDIF}
tkLString:
begin
_LStrAsg(_PAnsiStr(DestOff)^, _PAnsiStr(SrcOff)^);
Inc(Offset, SizeOf(Pointer));
end;
tkWString:
begin
_WStrAsg(_PWideStr(DestOff)^, _PWideStr(SrcOff)^);
Inc(Offset, SizeOf(Pointer));
end;
tkUString:
begin
_UStrAsg(PUnicodeString(DestOff)^, PUnicodeString(SrcOff)^);
Inc(Offset, SizeOf(Pointer));
end;
tkVariant:
begin
_VarCopy(PVarData(DestOff)^, PVarData(SrcOff)^);
Inc(Offset, SizeOf(TVarData));
end;
tkArray:
begin
EFT :=
PFieldTable(PByte(FTypeInfo) + Byte(PTypeInfo(FTypeInfo).Name[]));
_CopyArray(DestOff, SrcOff, EFT.Fields[].TypeInfo^, EFT.Count);
Inc(Offset, EFT.Size);
end;
tkRecord:
begin
EFT :=
PFieldTable(PByte(FTypeInfo) + Byte(PTypeInfo(FTypeInfo).Name[]));
_CopyRecord(DestOff, SrcOff, FTypeInfo); Inc(Offset, EFT.Size);
end;
tkInterface:
begin
{$IFDEF WEAKINTFREF}
if I > J then
_IntfWeakCopy(IInterface(PPointer(DestOff)^),
IInterface(PPointer(SrcOff)^))
else
{$ENDIF}
_IntfCopy(IInterface(PPointer(DestOff)^),
IInterface(PPointer(SrcOff)^));
Inc(Offset, SizeOf(Pointer));
end;
tkDynArray:
begin
_DynArrayAsg(PPointer(DestOff)^, PPointer(SrcOff)^, FTypeInfo);
Inc(Offset, SizeOf(Pointer));
end;
else
Error(reInvalidPtr);
end;
end;
end;
if FT.Size > Offset then
Move(Pointer(PByte(Source) + Offset)^,
Pointer(PByte(Dest) + Offset)^,
FT.Size - Offset);
end; procedure _CopyObject(Dest, Source : Pointer; vmtPtrOffs : NativeInt; TypeInfo : Pointer);
var
SavedVmtPtr : Pointer;
begin
SavedVmtPtr := PPointer(PByte(Dest) + vmtPtrOffs)^;
_CopyRecord(Dest, Source, TypeInfo);
PPointer(PByte(Dest) + vmtPtrOffs)^ := SavedVmtPtr;
end; procedure _CopyArray(Dest, Source, TypeInfo : Pointer; Count : NativeUInt);
var
FT : PFieldTable;
begin
if Count = then
Exit;
case PTypeInfo(TypeInfo).Kind of
{$IFDEF WEAKREF}
tkMethod:
while Count > do
begin
_CopyClosure(PMethod(Dest)^, PMethod(Source)^);
Inc(PByte(Dest), SizeOf(TMethod));
Inc(PByte(Source), SizeOf(TMethod));
Dec(Count);
end;
{$ENDIF}
{$IFDEF AUTOREFCOUNT}
tkClass:
while Count > do
begin
_InstCopy(TObject(PPointer(Dest)^), TObject(PPointer(Source)^));
Inc(PByte(Dest), SizeOf(Pointer));
Inc(PByte(Source), SizeOf(Pointer));
Dec(Count);
end;
{$ENDIF}
tkLString:
while Count > do
begin
_LStrAsg(_PAnsiStr(Dest)^, _PAnsiStr(Source)^);
Inc(PByte(Dest), SizeOf(Pointer));
Inc(PByte(Source), SizeOf(Pointer));
Dec(Count);
end;
tkWString:
while Count > do
begin
_WStrAsg(_PWideStr(Dest)^, _PWideStr(Source)^);
Inc(PByte(Dest), SizeOf(Pointer));
Inc(PByte(Source), SizeOf(Pointer));
Dec(Count);
end;
tkUString:
while Count > do
begin
_UStrAsg(PUnicodeString(Dest)^, PUnicodeString(Source)^);
Inc(PByte(Dest), SizeOf(Pointer));
Inc(PByte(Source), SizeOf(Pointer));
Dec(Count);
end;
tkVariant:
while Count > do
begin
_VarCopy(PVarData(Dest)^, PVarData(Source)^);
Inc(PByte(Dest), SizeOf(TVarData));
Inc(PByte(Source), SizeOf(TVarData));
Dec(Count);
end;
tkArray:
begin
FT := PFieldTable(PByte(TypeInfo) + Byte(PTypeInfo(TypeInfo).Name[]));
while Count > do
begin
_CopyArray(Pointer(Dest), Pointer(Source),
FT.Fields[].TypeInfo^, FT.Count);
Inc(PByte(Dest), FT.Size);
Inc(PByte(Source), FT.Size);
Dec(Count);
end;
end;
tkRecord:
begin
FT := PFieldTable(PByte(TypeInfo) + Byte(PTypeInfo(TypeInfo).Name[]));
while Count > do
begin
_CopyRecord(Dest, Source, TypeInfo);
Inc(PByte(Dest), FT.Size);
Inc(PByte(Source), FT.Size);
Dec(Count);
end;
end;
tkInterface:
while Count > do
begin
_IntfCopy(IInterface(PPointer(Dest)^), IInterface(PPointer(Source)^));
Inc(PByte(Dest), SizeOf(Pointer));
Inc(PByte(Source), SizeOf(Pointer));
Dec(Count);
end;
tkDynArray:
while Count > do
begin
_DynArrayAsg(PPointer(Dest)^, PPointer(Source)^, TypeInfo);
Inc(PByte(Dest), SizeOf(Pointer));
Inc(PByte(Source), SizeOf(Pointer));
Dec(Count);
end;
else
Error(reInvalidPtr);
end;
end; procedure CopyArray(Dest, Source, TypeInfo : Pointer; Count : NativeInt);
begin
if Count > then
_CopyArray(Dest, Source, TypeInfo, Count);
end; procedure InitializeArray(p : Pointer; typeInfo : Pointer; elemCount : NativeUInt);
begin
_InitializeArray(p, typeInfo, elemCount);
end; procedure FinalizeArray(P, TypeInfo : Pointer; Count : NativeUInt);
begin
_FinalizeArray(P, TypeInfo, Count);
end; procedure _Initialize(p : Pointer; typeInfo : Pointer);
begin
_InitializeArray(p, typeInfo, );
end; function _Finalize(p : Pointer; typeInfo : Pointer): Pointer;
begin
Result := _FinalizeArray(p, typeInfo, );
end; function _New(Size : NativeInt; TypeInfo : Pointer): Pointer;
begin
GetMem(Result, Size);
if Result <> nil then
_Initialize(Result, TypeInfo);
end; procedure _Dispose(P : Pointer; TypeInfo : Pointer);
begin
_Finalize(P, TypeInfo);
FreeMem(P);
end;

Delphi -- Compiler helper for initializing/finalizing variable的更多相关文章

  1. The CompilerVersion constant identifies the internal version number of the Delphi compiler.

    http://delphi.wikia.com/wiki/CompilerVersion_Constant The CompilerVersion constant identifies the in ...

  2. Delphi Compiler Bug?

    I found a Bug of Delphi XE3 Compiler,It may exists in XE4,XE5. Here is the code to show the bug proc ...

  3. Delphi For Linux Compiler

    Embarcadero is about to release a new Delphi compiler for the Linux platform. Here are some of the k ...

  4. Delphi XE2 compiler performance

    原文: http://blog.barrkel.com/2011/10/delphi-xe2-compiler-performance.html Delphi XE2 compiler perform ...

  5. Delphi CompilerVersion Constant / Compiler Conditional Defines

    http://delphi.wikia.com/wiki/CompilerVersion_Constant The CompilerVersion constant identifies the in ...

  6. Delphi XE5教程11:Tokens

    内容源自Delphi XE5 UPDATE 2官方帮助<Delphi Reference>,本人水平有限,欢迎各位高人修正相关错误!也欢迎各位加入到Delphi学习资料汉化中来,有兴趣者可 ...

  7. How to create functions that can accept variable number of parameters such as Format

    http://www.chami.com/tips/delphi/112696D.html Sometimes it's necessary to pass undefined number of [ ...

  8. DLL Injection with Delphi(转载)

    原始链接 I had recently spent some time playing around with the simple to use DelphiDetours package from ...

  9. Delphi Waring 的信息

    Display PreferencesWarning messages (Delphi)Go Up to Delphi Compiler Directives (List) Index TypeSwi ...

随机推荐

  1. ps命令介绍

    ps是收集进程信息的重要工具.它提供的信息包括:拥有进程的用户.进程的起始时间.进程所对应的命令行路径.进程ID(PID).进程所属的终端(TTY).进程使用的内存.进程占用的CPU等.例如: $ p ...

  2. 完全背包问题 POJ1384

    完全背包即物品的数量不收限制, 根据01背包的思想,因为每件物品只能选1个,则要求我们不能依赖已选择物品i的选项的时候,所以需要逆序遍历 则在完全背包问题中,我们需要正序遍历. 此题时要求求出最小价值 ...

  3. Floyd | | jzoj[1218] | | [Usaco2009 Dec]Toll 过路费 | | BZOJ 1774 | | 我也不知道该怎么写

    写在前面:老师说这一道题是神题,事实上确实如此,主要是考察对Floyd的理解 ******************************题目.txt************************* ...

  4. Fiddler怎么对IPhone手机的数据进行抓包分析

    http://www.cr173.com/html/20064_1.html Fiddler绝对称得上是"抓包神器", Fiddler不但能截获各种浏览器发出的HTTP请求, 也可 ...

  5. memalign vs malloc - 使用O_DIRECT参数open一个文件并读写

    听说使用odirect参数打开文件时能够以扇区的单位进行读写. 于是open了一个块设备文件/dev/sdo,当然还要带上读写参数O_RDWR 然后进行读写时出错了. 找了一会发现问题根本在于读写的b ...

  6. BZOJ 4247: 挂饰 题解

    Description JOI君有N个装在手机上的挂饰,编号为1...N. JOI君可以将其中的一些装在手机上. JOI君的挂饰有一些与众不同--其中的一些挂饰附有可以挂其他挂件的挂钩.每个挂件要么直 ...

  7. 奇葩问题之ToolBar返回键失效

    今天遇到一个奇葩问题,先说现象:接口调用成功,但是在后台业务上报错时(比如:手机号已经被注册过时,接口调用成功,但是后台返回了错误信息:手机号已被注册),toolBar的返回键失效了. 后来仔细看了一 ...

  8. 解决VS2010链接错误:LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏

    网上有多种解决办法,我用最懒的一种,系统是Win7 X86,方法如下: C:\Windows\Microsoft.NET\Framework\v4.0.30319\cvtres.exe C:\Prog ...

  9. php redis 代码实例

    <?phpheader("Content-type:text/html;charset=utf8");$redis = new redis();$redis ->con ...

  10. elixir 高可用系列(四) Task

    概述 之前学习的 Agent,GenSever以及GenEvent,都是用来管理状态或者处理消息的. 但是在很多时候,我们需要的是执行某个任务,这时如果使用 GenSever 或者 GenEvent, ...