#include<stdio.h>
int size 1000
void *a;
static int freeindex;
void *malloc(int n)
{t
           if( n<(1000-freeindex) )
              {
                  p=freeindex;
                  freeindex=freeindex+n;
                }
  else
           printf(" insufficient memory");
return a+p;
}

i dont think it exactly correct but you have to use the concept of the
static variable here because it will remember the value of variable during
recalling of function

   i presented here it because by seeing atleast one of you will get the
idea.....
so friends try to understand it write even i want the correct code for it

i think my code wont work


On Tue, Aug 2, 2011 at 10:10 PM, rShetty <rajeevr...@gmail.com> wrote:

> Could anyone provide an algorithm/code and explanation for
> implementation of malloc() in C .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to