free

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anilk501
    New Member
    • Oct 2006
    • 7

    free

    1)why is not a pointer null after calling free?
    2)what is the warning : "macro replacement with string literal" means?
    3)is it safe to take advantage of calloc's zero fillings?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    1)why is not a pointer null after calling free?
    Since the pointer is passed to the function free by value free can not changed the value of the pointer. If you want it to be NULL after calling free set it to NULL.

    2)what is the warning : "macro replacement with string literal" means?
    No idea, show us the code that produced it.

    3)is it safe to take advantage of calloc's zero fillings?
    If you mean is it safe to assume that calloc zero's the memory it has allocated then yes as long as you are fairly sure that your platforms implementation of the standard library functions is reliable.

    Comment

    • tyreld
      New Member
      • Sep 2006
      • 144

      #3
      Regarding Question 2

      Basically, some pre-ANSI compilers allowed you to expand macro parameters inside of string literals and character constants. This behavior allowed both confusing and dangerous macros.

      Neither, ANSI or K&R C define this behavior. Instead they provide the # macro operator for turning macro arguments into strings.

      Most modern day compilers won't even check for this behavior.

      The following in the comp.long.c FAQ answers this slightly more in depth and provides examples.

      Comment

      Working...