[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
 

malloc_usable_size ?



Hejsan !

Har gjort ett litet program för att allokera mine. Efter malloc, så vill ajg
veta hur många bytes malloc har allokerat. Trodde att det skulle fungera bra
med malloc_usable_size(*ptr). När jag skriver ut resultatet av ovanstående, så
visar det sig att den returnerar 12 första gången jag köra malloc och varje
gång jag ändrar storlek med realloc, så läggs det till 8. kan förresten berätta
att det är ett gäng int:ar jag hade tänkt använda som enligt sizeof(int) är 4
bytes på mitt redhat system. Jag använde egcs för att kompilera programmet.

Om egcs hade/är förberett för 64 bitars processorer, så kan jag förstå de 8
extra byten, men de 12 i början hänger jag inte med på.

Någon som kan förklara varför ??

Kodexempel:

int main()
{
int *tal;

tal=(int*)malloc(sizeof(int));
printf("%d\n",malloc_usable_size(tal)); // Resultatet här blir 12
tal=(int*)realloc(tal,malloc_usable_size+sizeof(int));
printf("%d\n",malloc_usable_size(tal)); // Resultatet här blir 12+8=20.

return(0);
}
 
---

/Jocke

ICQ uin: 3939304

----------------------------------------------------------------

***     Linux..... The choice of a thinking generation     *****

----------------------------------------------------------------



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 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] *