www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/10/12/07:31:56

To: djgpp AT sun DOT soe DOT clarkson DOT edu
From: HLI AT trisse DOT hj DOT se
Organization: H”gskolan i J”nk”ping
Date: 12 Oct 93 12:03:34 MET+1
Subject: Malloc and free

    Hello !

    I have made a small program which is supposed to alloc
    and free memory. The problem is that it dosen't free
    the allocated memory at all.

    #include <stdio.h>
    #include <malloc.h>

    void main ()
        {
        int c;
        void *p;

        c=0;
        while (c<800)
            {
            printf ("malloc: %d bytes \n",c*10000);
            p=malloc (c*10000);
            memset (p,0xff,c*10000);
            free (p);
            getch ();
            c+=100;
            }
        }

    I compile the program using: gcc prog.c -Wall

    Why is'nt the memory free'd ?

    I use gcc 2.2.2




+---------------------------------------------------+

    hli AT tekn DOT hj DOT se
    Henric Linden
    H|gskolan J|nk|ping / J|nk|ping University
    P.O Box 1026
    551 11 J|nk|ping, Sweden

+---------------------------------------------------+

- Raw text -


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