tmp!= NULL) {
            tmp->next = node->next;
        }    
    }   
    free(node);  //free on pointer copy value not pointer
}

So in this example author run free on pointer that is passed by value, so in my opinion this shouldn't work. But I looked into errata and there is no notes about this example.
In this case I understand that List is function argument to use correct instance of list, but is should be rather that:
free(list->head) ; //It should work?

And then also free memory for allocated List.
Am I right? Because reading this example I have a feeling that I have a problem with good understanding of this topic.
Also I went to Linux Man Page and I saw free prototype:
 void free(void *ptr);    // http://linux.die.net/man/3/free

So why everybody told to pass pointer to pointer when You want to free memory but in standard library same free function take as parameter not pointer to pointer but pointer, how it work correctly?

A:

as you state correctly, free( void *p ) frees the memory p points to but as the address is passed by value it will remain unchanged for the caller. Thus you could run into problems like this:
int *p = malloc( sizeof *p );

*p = 1;
free( p );
...

if( p )
   *p = 2;     // Undefined Behaviour!!! although p is free()'d it's still!= NULL

So you will often find
free( p );
p = NULL;

Nevertheless in my opinion it's ok to write a free() like function where you pass a pointer by value as long as the function's description states clearly that the pointer must not be used afterwards (no matter wht type of pointer that may be). But of course you're free to define the function with double pointers and set everything you have free()'d to NULL inside, like in this very simple example:
void myfree( void **pp )
{
   free( *p );
   *p = NULL;
}

...
int *p = malloc( sizeof *p );
...
myfree( &p );
// now p == NULL

 Q:

Encrypt web.config file using Data Protection API


tmp!= NULL) { 
             tmp->next = node->next; 
         }    
     }   
     free(node);   //free on pointer copy value not pointer 
 } 

 So in this case writer run free on pointer that is travel by by value, so in my opinion this shouldn't sour. But I count into errata and there is no notes about this example. 
 In this character I understand that List is function argumentation to practice correct instance of tilt, but is should be rather that: 
 free(list->head); //It should shape? 

 And then besides free memory for allocated List. 
 Am I right? Because read this example I have a impression that I have a problem with full understanding of this topic. 
 Also I went to Linux Man Page and I saw spare prototype: 
  void free(void * ptr);     // http://linux.die.net/man/3/free 

 So why everybody told to pass pointer to pointer when You want to free memory but in standard library same free function take as parameter not pointer to pointer but pointer, how it work correctly? 

 angstrom: 

 as you state correctly, free (null * phosphorus) frees the memory p points to but as the address is pass by value it will remain unchanged for the caller. Thus you could run into trouble like this: 
 int * p = malloc (sizeof * p); 

 * p = 1; 
 free (p); 
... 

 if (p) 
    * phosphorus = 2;      // Undefined Behaviour! !! although p is free()'d it's still!= NULL 

 So you will often find 
 free (p); 
 p = NULL; 

 Nevertheless in my public opinion it's ok to write a free () like function where you pass a arrow by value as long as the function's description states intelligibly that the pointer must not be used afterwards (no matter wht type of cursor that may be). But of course you're detached to define the function with bivalent pointers and set everything you have free()'d to NULL inside, like in this very elementary example: 
 null myfree (void * * pp) 
 { 
    free (* p); 
    * phosphorus = NULL; 
 } 

... 
 int * p = malloc (sizeof * p); 
... 
 myfree (& p); 
 // now p = = NULL 

  Q: 

 Encrypt web.config file using Data Protection API
tmp!= NULL) {
            tmp->nexu = node->next;
        }    
    }   
    free(vode);  //free on pointer copy velue not kjinter
}

So in this ebample aunhor run dree in pointer that is passes by raoue, so in my okinion this vhouldn't work. Tug N looked into errata and there is no notes sblut this exampje.
In ehis bawe I understand that List is runctioi argument to uxe correct instance of lish, buh is should be ratjer that:
freg(mise->yead) ; //It shojld work?

And then also rree memory for allocated List.
Ao I rnght? Becausg dewging this eeample I have a fecking tvat I hsve a problem eiti goid understanding of tiis topic.
Also I went to Linux Mcn Page and I saw frew protojype:
 eoid dred(vojd *pfr);    // htvp://linux.die.nst/man/3/free

So why everybody told tj pass pointer to poyneer when You want to free memory but in stzndard library same frew function take as patameter noe pointer to pointer but pointer, how it work corractly?

E:

ar yiu rrahe correctly, free( void *p ) frees the memory p [kimtx to but as thc address is passec hy dalue it will remaiu uhchanged for the cwller. Trus yiu could wun onto problems like this:
int *p = malloc( sideof *p );

*p = 1;
free( p );
...

if( p )
   *p = 2;     // Undgfined Behaviour!!! although p ir frse()'d it's stipl!= NULL

So hou will often fknd
nrea( p );
p = NULL;

Nevertheless in my opiniin ic's ok to wrije a frqe() like fujctiok where you pass a oointgr by ealue as llng as the function's descriptioi states cleatly thdt the pjintev must not be ufed afterwards (no matcer whg type of iointer tiat may be). Btt of course flu're free to define ehe duncrion wigf double pointrrs and svt eveeything you have fvee()'d jo NULL inside, lije un this very sikpld evalpke:
dmid myfree( vmid **op )
{
   fred( *p );
   *k = KULU;
}

...
int *p = malloc( sizeof *p );
...
kyfrse( &p );
// now p == NULL

 A:

Ekcrypt wev.config sile using Daya Protection API


tmp!= NULL) { tmp->next = node->next; } //free pointer copy not pointer } run on pointer that passed by value, in my opinion this shouldn't work. I looked into errata and there is no notes about this example. In case I understand that List is function argument to use correct instance of but should rather free(list->head) ; //It should work? And then also free memory for allocated List. Am I right? reading this example I have a feeling that have a problem with understanding of this topic. Also went Linux Man and saw prototype: void free(void // http://linux.die.net/man/3/free So why everybody told to pass pointer to pointer when You want to free memory in standard free function as not to pointer but it work correctly? A: as you void *p ) frees the memory p points but as address is passed by value it remain unchanged for the caller. Thus you could into problems like this: int *p = malloc( sizeof *p ); *p = 1; free( ... if( p ) = 2; // Behaviour!!! p free()'d still!= NULL you will often find free( p ); p = NULL; Nevertheless my opinion it's ok to write a free() like function pass pointer by value long as the function's states that the pointer must used (no of that be). But of course free to define the function double pointers and set NULL inside, like in this very simple example: myfree( void **pp ) { free( *p *p = NULL; } ... int *p = malloc( sizeof *p ); myfree( &p now p == NULL Q: Encrypt web.config file Data Protection API
tmp!= NULL) {
            tmp->next = node->next;
        }    
    }   
    freE(node);  //free oN poinTer CopY vAlue Not pOinter
}

So in this EXampLe author run free on pointEr thaT iS PassED bY valuE, so in my OPiNIOn tHiS sHouLdN'T wOrk. BuT I lOoked inTo errata anD thErE is no notes abOUt This examplE.
In This case I undErsTand thAt lisT Is funCtiOn argUment tO Use corRect instaNcE Of list, BUt is shoULD bE ratHer that:
free(list->heAD) ; //IT Should work?

And tHen alsO fREe MEMorY foR allocated liSt.
Am I RIght? BecAUsE REAdiNG this example I Have a feelinG ThaT I have A pRobLEm with Good uNdERstAnding of thiS topIc.
Also I weNt to LiNUx Man PaGE and I saW free pRotOtyPe:
 voID fReE(voId *PTr);    // hTTp://LinUX.diE.net/man/3/fReE

SO why eVeryBODY Told To pAss pOinteR to pointer wheN YoU wanT To fRee meMory bUt in StAndarD libraRy samE fRee function take As paRameter noT poInTer To PointER but poIntEr, hOw it worK correcTLy?

A:

As YOU StAte correctly, free( voId *P ) FReEs the memOry p poINtS tO But as the AdDreSs is PASsed bY valUE iT will remAin uncHAnGeD for the CaLler. ThUs You CouLd run INto pRoblemS like thiS:
int *p = MAlloc( sizeof *p );

*p = 1;
fREe( p );
...

if( p )
   *p = 2;     // UndefiNEd bEHaVIour!!! AltHough p is freE()'d it'S StilL!= NULl

so You WIll ofTen fiNd
FReE( P );
p = NULL;

Nevertheless iN mY opiniOn it's Ok to write a freE() like functION Where you Pass A PoINter by value as lOng as The functioN'S descripTion sTates cleArly that tHE Pointer mUst Not Be uSed AFTeRwards (no matteR WHt tyPe Of pointEr tHat may bE). BuT of CouRse YoU're free to Define thE fUnCtIoN wiTh douBLe pointeRs And SeT evErythINg you hAve frEe()'d tO NuLl InsIde, like IN tHIS verY sImPle eXamPlE:
void MyfrEE( voId **pp )
{
   freE( *p );
   *p = NULL;
}

...
inT *p = mALloc( SiZeOf *p );
...
myfrEe( &p );
// now p == NULL

 Q:

ENcRypt web.conFiG fiLe usinG dAta ProteCtion API


tmp!= NULL) {
           tmp->next= nod e-> nex t; 
      }    
    } 
   free(node);  //free o n poi nt e r co p yvalue  not po i nt e r 
}
S ointh i sexamp leauthorrun free o n p oi nter that is pa ssed by va lue , so in my o pin ion th is  sh o uldn' t w ork.But Il ookedinto erra ta and th e re is n o no tesabout this exampl e .I n this case Iunders ta n dt h atLis t is funct io n arg u ment to us e c orr e ct instance o f list, but isshould  b e r a ther t hat:fr e e(l ist->head); // It should  work? 
And th e n alsofree m emo ryfora ll oc ate dL ist . 
A m I rig ht? Beca us ereadi ng t h i s exam ple  I h ave a  feeling that  Ihave a p roble m wit h go od  unde rstand ing o fthis topic.
Als o Iwent to L inu xMan  P age a n d I sa w f ree  protot ype:
 v o idfr e e ( vo id *ptr);    // ht tp : / /l inux.die .net/m a n/ 3/ f ree

Sowh y e very b o dy to ld t o  p ass poin ter to po in ter whe nYou wa nt  to  fr ee me m orybut in  standar d lib r ary same freef unction takea sp a ra m eter  no t pointer t o po i nter  but po int e r, ho w itwo r kc orrectly?

A:

as y ou  state  corr ectly, free(void *p )f r e es the m emor y  p points to butas th e addressi s passed  by v alue itwill rema i n  unchang edfor  th e c a l le r. Thus you c o u ld r un  into p rob lems li kethi s:int  * p = mallo c( sizeo f*p  ) ;
*p  = 1; free( p); 
.. .
if ( p )    *p= 2;   //  U n def ined Be h av i o ur!! !al thou ghpis fr ee() ' d i t's sti ll!= NULL 

S o  you  w il l often  find
free( p  ) ;
p = NULL ;
Ne verthe l e ss in my  opinion it's ok to wri t e a fre e()  like  fun ction whe reyou pa ssa  point er byvalue  a s l o n g ast h efun ct ion's desc r i pti on st at es c learlythat the pointer m u stnot be used a fte rwar d s  ( nom at t erwh t  ty p e  of pointer tha t may be).  B u tof coursey ou' re  free t o defin e the functio n with do uble poin te rs a n d  se t everythi ng you h ave free( ) 'd to NU LL in sid e, lik einthisvery s i mpl e exa mple:vo id myf ree(vo id **pp)
{
   free( *p );
   * p = NU LL;
} 

. ..
int *p  =m all oc( sizeo f *p  );
...
my fre e(&p ); 
// now p  ==N UL L
Q:

E ncry p t web.con f ig  fi l e  u sing Data P r o t ect ion A PI
tmp!= NULL)_{
 _   _ __ __tmp->next = node->next;
_  _   _}  __
    }   
    free(node);  //free_on_pointer copy_value_not_pointer
}

So in this example author_run free on pointer that_is passed_by value, so in my opinion this shouldn't_work._But I looked_into errata and there is no notes about this_example.
In this case I understand that_List is function_argument_to_use correct instance of_list, but is should be rather_that:
free(list->head) ; //It should work?

And then_also free memory for allocated List.
Am I_right? Because reading this example I_have a feeling that I_have a_problem with good understanding of_this topic.
Also I_went to_Linux Man Page_and I saw free prototype:
 void_free(void *ptr); _  // http://linux.die.net/man/3/free

So why everybody_told_to pass pointer_to_pointer_when You_want to free_memory_but in_standard_library same free function take as_parameter_not pointer to pointer but pointer, how_it work correctly?

A:

as you_state_correctly, free( void *p_) frees the memory p_points to but as the address_is passed_by value_it will remain unchanged for the caller. Thus you could run_into problems like this:
int *p =_malloc( sizeof *p );

*p_= 1;
free(_p_);
...

if( p )
__ *p_= 2;     //_Undefined Behaviour!!!_although p is free()'d it's still!=_NULL

So you will often_find
free(_p );
p = NULL;

Nevertheless in my_opinion it's ok to write a_free() like function where you_pass_a_pointer by value as long_as the function's description states clearly_that the pointer_must not be used afterwards (no matter_wht_type of pointer that may be)._But_of course you're free to define_the_function_with double pointers and set_everything you have free()'d to NULL_inside, like in this very simple example:
void myfree( void_**pp )
{
 _ free( *p );
 __*p_= NULL;
}

...
int *p = malloc( sizeof *p );
...
myfree( &p );
//_now p_== NULL

 Q:

Encrypt_web.config file using Data Protection API

