[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Segfejl under kørsel, men ikke når jeg debugger!



On Wed, 23 Jun 2004 09:29:27 +0200, Bo Simonsen wrote:

>> 	char	*type = (char *) malloc(sizeof(int) * 25);
> Sizeof int giver jo ikke længden af et tal, men blot den størrelse du
> skal bruge i hovedlaget på at gemme en integer (4 bytes i non-packed
> version).
En fejl. Skal være sizeof(char)
> 
> Så alloker mere end du skal bruge (hvilket jeg også tror du gør?),
> ellers har du en potionentiel segfault/memory leak.
Ovenstående retter vist denne fejl?
> 
> BTW Bliver GCC ikke sur over du kalder metoder ved defintion af variable?
> Men det kommer selvføglelig an på om du bruger C++ delen i gcc. Det er
> nemlig tilladt i C++ men ikke i C.
Ingen warning eller fejl. Det er ikke c++ versionen, jeg benytter, men
gcc3.3. Det er vist nok tilladt i C99.
> 
> Hvorfor ikke bare bruge et array af char til type?
> 
Ingen fornuftig begrundelse udover at jeg føler mig mere hjemme med
pointere, og samtidigt synes jeg også, det ser "pænere" ud:-)
> Må vi ikke læse 0 bytes? Næ.. For så har select selvføglelig dummet
> sig på en måde, får du nogensinde den fejl?
Ja, det var det, der var baggrunden for hele starten af tråden. Hvis man
operere med tråde, kan du komme i den situation, at tråden forsøger at
læse/skrive før input er klar (while ((c = fgetc(FILE)) != EOF)
fputc(FILE, c);)
>
> Ser ellers udemærket ud. :)
Takker:o)
-- 
Hilsen/Regards
Michael Rasmussen

Get my public GnuPG keys:
mir <at> datanom <dot> net
http://search.keyserver.net:11371/pks/lookup?op=get&search=0xE501F51C
mir <at> miras <dot> org
http://search.keyserver.net:11371/pks/lookup?op=get&search=0xE3E80917
--------------------------------------------------------------
Don't get to bragging.




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *