will I get Memory leak..



Hi all,

void main()
{
char *fp;
fp=malloc(26);
strcpy(fp,"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
fp[10]='\0';
free(fp);
}

Please refer the program for my questions..

1. Can any one tell me if would i assign '\0' at middle of
dynamically assigned memory area will i get memory leak.. ??
2 . Will "free()" delete all the memory which allocated by
dynamically even NULL values has been added in middle of that.??
3. How let i know that will i get memory leak in a program?? any
compiler option are there ?? Can i use splint tool ?

Thanks,
Ganesh

.



Relevant Pages

  • Re: will I get Memory leak..
    ... char *fp; ... Please refer the program for my questions.. ... dynamically assigned memory area will i get memory leak.. ... How let i know that will i get memory leak in a program?? ...
    (comp.lang.c)
  • Re: will I get Memory leak..
    ... dynamically assigned memory area will i get memory leak.. ... BTW, NULL is not the same as '\0'. ...
    (comp.lang.c)
  • Re: will I get Memory leak..
    ... dynamically assigned memory area will i get memory leak.. ... BTW, NULL is not the same as '\0'. ...
    (comp.lang.c)
  • Re: Allocating memory for struct - when?
    ... > believe it is because there's some memory leak - the debugger tells me ... instead of "char". ... how would the compiler know how much memory to ... example of a situation that flexible array members were designed for. ...
    (comp.lang.c)
  • Re: xmalloc string functions
    ... char *foo, *bar; ... will quit and a memory leak will occur because the return ... value of dup() was not freed */ ...
    (comp.lang.c)