This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strange bug that doesn't occur in Linux, OpenBSD or ITS

Jeremiah Bishop writes:
> the bash commands used are:
> 1) gcc "cygwin puzzle.c" 
> 2) ./a.out a b
> Now either version used on a file with a shorter set of lines, works just fine
but strangely, that single
> digit difference aborts the program without throwing any error on the sample
input or text files with
> similarly long lines.
> Perhaps that has been covered before but 3 hours of searching the archives did
not yield any helpful results
> [perhaps I used the wrong search criteria? ]
> any tips or hints on what has gone wrong will be helpful.

1. This has nothing to do with Cygwin, but rather basic programming safety

2. You aren't checking the result of malloc() to see if it's NULL before using
it.  The heap (where malloc() gets its memory) is not infinite and varies in
size between platforms.

3. You didn't say what happened when you ran the program, so I had to audit it
and run it and watch it laboriously consume memory until I ran out of patience.

4. You've coded functions nested inside main().  I haven't seen that practice 
in C language before but apparently it works.  Color me impressed.

That's all I've got.


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]