C (104/257)

From:
Date:09 Feb 2001 at 21:06:31
Subject:Re: Alloc/Free___ Chip memory fragmentation

Czesc William!

Dnia 09-Lut-01, William Robinson napisa�:

>If I could afford a better accellerator, beleive me, i would get
>one. i'm just trying to grab people's SIMM chuckouts at the moment so
>i've got a bit more RAM and also and an internal harddisk. I think i do
>have an MMU. It's the Blizzard 1230 mk. IV which i'm pretty sure has
>one, although i've never tried any virtual memory stuff really.
>I looked at enforcer recently, but i haven't gotten around to
>trying and sorting it all out. I thought it looked a bit much for what i
>was trying to solve.

If you have MMU that's good. After I'll go home I'll send you scripts with
optimal options for debug utilities which I use everyday...

>problems with my uni work, but trying to get something i've written into
>the public domain has always proved a problem due to frustration at
>unfindable bugs.

Maybe you're trying to create too big project in AmigaOS at once? If something
doesn't work well in big project try to write small test program which will do
specified work... You will be able to find bugs faster. And if problems are
too serious, you can post info about them here...

> I'm currently attempting to transfer a Graphic
>Adventure engine that i programmed in Blitz Basic last summer, into C++.
>As well as the fact that i now much prefer the C/C++/Java
>object-oriented style, i want to then write a graphics interface for a
>PC (at some point).

Graphics User Interface? Like MUI? ;)

>i will have a look at the newer graphics library. the only thing
>i've really been learning from is the old RKMs on the Amiga Developers
>CD 2.1, so thank you very much for your time :o).

Amiga Developer CD v2.1 is the latest developer kit for Amiga programmer as
far as I know. You can find anything what you want to programme AmigaOS
applications.

>What tools do you regularly use for debugging? I've heard of
>enforcer many times, but whenever i read the overview of it, i don't
>bother installing it. It says that it just checks for illegal memory
>allocations.

Enforcer/MuForce checks for illegal memory access not allocations, for example
if you use uninitialized/not valid address variable:

UBYTE *data = NULL;
// forgot to allocate data here.
*data = 0;

Mungwall/MuGuardianAngel patches memory allocation functions of exec.library
and install walls with specified size before and after allocated memory:

UBYTE *data;
if( data = AllocMem( 100, MEMF_ANY ) )
{
data[ -1 ] -= 1;
data[ 101 ] += 1;
}

Modyfing memory that isn't allocaed by your program is a serious problem when
you're not using string functions with constant size...

UBYTE string[ 5 ]; (String could by dynamically allocated here, size 5 is only
for example ;)
strncpy( string, "hello world!\n", sizeof( string ) ); // memory will not be
corrupted.
strcpy( string, "hello world!\n" ); // memory will be corrupted.
sprintf( string, "hello world %ld!\n", i ); // memory will be corrupted.

Similar example as your's previous source code:

if( bitmap ) { [...] FreeVec( bitmap ); }
printf( "%ld\n", bitmap->Planes[ 0 ] ); // memory is freed, bitmap pointer
isn't valid any more.

> When I run the program from within StormC, i get a load of
>error messages there about that anyway.

Run debug utilities and you will see much more of them ;).

Regards!



Can your ImageFX paint like bitmap painters?
Download: gfx/ifx/REDFiX.lha, ftp.novadesign.com

Przemyslaw 'SENSEI' Gruchala

code/gfx2d/gfx3d/webmaster

Amiga 1200
Apollo 1240/33 MHz, 18 MB RAM, BTC 33.6 bps
HDD 3.2 GB, HDD 520 MB, CD x12



Podnies kwalifikacje swoich pracownikow !
Profesjonalne szkolenia, konsultacje, doradztwo. Najlepsi specjalisci.
Kliknij: Akademia Skutecznego Biznesu: www.asb.com.pl !

------------------------ Yahoo! Groups Sponsor ---------------------~-~>
eGroups is now Yahoo! Groups
Click here for more details
http://click.egroups.com/1/11231/0/_/451227/_/981752542/
---------------------------------------------------------------------_->