TIP: Click on subject to list as thread! ANSI
echo: tub
to: Bo Simonsen
from: Bob Jones
date: 2003-10-05 06:42:38
subject: Sqfix problem

BS>> Of some reason sizeof(XMSG) doesn't give the exact
 BS>> size, the problem did Squish also have but i fixed it
 BS>> there, but #define'ing XMSG_SIZE in msgapi, it was
 BS>> right after the porting of maximus..

 BJ> Ah....  That would explain it.....  Yes, sizeof() may not
 BJ> work in all environments now.....  :(

 BS> Well I just don't understand it, because it does 
 BS> normally work under Linux, maybe it's the arrays..

The problem is that sizeof() returns the number of bytes
in memory.  By default, structures are not packed.  If the structure was
packed, then sizeof() should have worked for reading and
writing files.  Wes has a define made to allow packing the structures under
GCC but not on other compilers where the packing isn't needed.  Any
structure that has more than one item (which it should or you wouldn't have
used a structure), and has elements that are not an exact multiple of 4 or
8 bytes may get located on 4 (or 8) byte boundaries, resulting in unused
bytes in the structures memory immage.  So, sizeof() is
needed for memory copies, but fail when reading and/or writing binary files
in these cases.....

Take care.....

Bob Jones, 1:343/41


--- Maximus/2 3.01
* Origin: Top Hat 2 BBS (1:343/41)
SEEN-BY: 633/267 270
@PATH: 343/41 10/345 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.