Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Compliant Solution 2

Code Block

/\* NOTE: buf must point to dynamically allocated memory \*/
void append(char \*buf, size_t count, size_t size) {   
  char *line = " <- THIS IS A LINE";   
  int line_len = strlen(line);    
  if ((count + line_len) > size)      
  buf = realloc(buf,count+line_len);   
  strncat(buf,line); 
}

References

Seacord 05 Chapter 4 Dynamic Memory Management

Wiki Markup
 MIT Kerberos 5 \[http://web.mit.edu/kerberos/advisories/MITKRB5-SA-2004-002-dblfree.txt