On 7-2-2012 19:48, Sven Barth wrote: > On 07.02.2012 17:12, Reinier Olislagers wrote: >> >> Code bombs at decoder.Read(a, readsize). readsize=0 according to >> debugger. >> readsize=cardinal; according to help "an unsigned 32-bit integer". >> However, >> http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide#32.2F64_bit >> >> seems to imply Cardinal can vary between 32 bit and 64 bit. >> >> Is that the culprit or am I doing anyth else wrong? Thanks, Sven!
> Does your stream contain at least 4096 bytes? According to the > documentation here > http://www.freepascal.org/docs-html/rtl/objects/tstream.read.html the > Read procedure does not perform any check. Yes, that should be the case, compressed size is 909094 bytes. The file uncompresses nicely with the bunzip2 executable. > Important note in case you're not aware of it: Tbzip2_decode_stream is > NOT a descendant of Classes.TStream, but of Objects.TStream, thus you > should look at the documentation of unit Objects (you can reach it from > the above mentioned link). Ok, thanks. > Also "Cardinal" is always 32-Bit wide. The only types that change > depending on bitness are "Pointer", "PtrUInt" and "PtrInt". Thanks. Let me verify if I understand correctly. The wiki article http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide#32.2F64_bit says: FPC defines two types for this: PtrInt and PtrUInt. PtrInt is a 32bit signed integer on 32 bit platforms and a 64bit signed integer on 64bit platforms. The same for PtrUInt, but unsigned integer instead. Use for code that should work with Delphi and FPC: {$IFNDEF FPC} type PtrInt = integer; PtrUInt = cardinal; {$ENDIF} So in Delphi, presumably cardinal varies between 32 and 64 bit, while in FPC it is always 32 bit. Or am I interpreting this incorrectly? I'll try and upgrade the FPC to SVN first - now at Free Pascal Compiler version 2.6.0-1 [2012/01/13] for i386 maybe it helps... (Probably not). I can also try the same code on Windows x86 to see what happens there... Any additional tips welcome... Thanks, Reinier _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal