delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/29/06:13:24

From: "HPMAN" <mwa DOT p AT infonie DOT fr>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Weird : Segmentation fault on fwrite :(
Date: Sat, 29 Apr 2000 11:47:38 +0200
Organization: Ye 'Ol Disorganized NNTPCache groupie
Lines: 47
Message-ID: <957001855.943830@romulus.infonie.fr>
References: <956963090 DOT 719428 AT romulus DOT infonie DOT fr> <20000429101940 DOT A22474 AT chance DOT cz>
NNTP-Posting-Host: romulus.infonie.fr
X-Trace: vulcain.infosources.fr 957001633 1222 195.242.64.111 (29 Apr 2000 09:47:13 GMT)
X-Complaints-To: abuse AT infonie DOT fr
NNTP-Posting-Date: 29 Apr 2000 09:47:13 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Cache-Post-Path: romulus.infonie.fr!unknown AT 195 DOT 242 DOT 67 DOT 51
X-Cache: nntpcache 2.4.0b3 (see http://www.nntpcache.org/)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Isn't the '&' supposed to be implicit with arrays ?

Always used an '&' with arrays and worked fine...

Thus, fwrite(TestBuff,sizeof(char),32,output); and
fwrite(&TestBuff,sizeof(char),32,output); aren't supposed to be the same ???

I agreed in case of a pointer, but with static arrays...

Why does it work in a program and not in another one ???

Could this be a specification to DJGPP ?


Anyway, I still have problem when writing a part of a buffer with :

fwrite(Clut,32,1,output);

Clut is declared as unsigned char *Clut;

and allocated with :
if((Clut=(unsigned char*)malloc(sizeof(unsigned char)*1048576))==NULL) {
  printf("Woops, out of memory !!!\n");
  exit(0);
}

allowing 1 Meg of memory (I don't use the full Meg, but since the buffer is
frequently accessed, I avoid many malloc and free, saving some speed...

And I get SIGABRT signal ....

This is in fact my main problem, since I found the other one trying to
resolve this one making some tests to see what's wrong...

Egon Eckert <egon AT chance DOT cz> a écrit dans le message :
20000429101940 DOT A22474 AT chance DOT cz...
> >         fwrite(&TestBuff,sizeof(char),32,output);
>
> This is wrong.  Try
>
> fwrite(TestBuff,sizeof(char),32,output);
>
> (without the '&').
>
> Egon Eckert


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019