Connecting Tech Pros Worldwide Forums | Help | Site Map

free

Newbie
 
Join Date: Oct 2006
Posts: 7
#1: Oct 6 '06
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's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,166
#2: Oct 6 '06

re: free


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.
Familiar Sight
 
Join Date: Sep 2006
Posts: 144
#3: Oct 6 '06

re: free


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.
Reply