free() bad
This commit is contained in:
6
printf.c
6
printf.c
@@ -19,7 +19,7 @@ int _printf(const char *format, ...)
|
|||||||
|
|
||||||
identifiers = _contains(format, '%'); /* instances of %s, %c etc */
|
identifiers = _contains(format, '%'); /* instances of %s, %c etc */
|
||||||
BUFF_SIZE = _strlen(format) - identifiers;
|
BUFF_SIZE = _strlen(format) - identifiers;
|
||||||
buffer = malloc(BUFF_SIZE); /* sized of the non % instances only*/
|
buffer = (char *) malloc(BUFF_SIZE); /* sized of the non % instances only*/
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
@@ -35,8 +35,8 @@ int _printf(const char *format, ...)
|
|||||||
if (buffer) /* printing and clearing buffer on formatted things */
|
if (buffer) /* printing and clearing buffer on formatted things */
|
||||||
{
|
{
|
||||||
printed += _puts(buffer);
|
printed += _puts(buffer);
|
||||||
free(buffer);
|
_memset(buffer, 0);
|
||||||
buffer = malloc(BUFF_SIZE);
|
buffer = (char *) malloc(BUFF_SIZE);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return (-1);
|
return (-1);
|
||||||
buff_idx = 0;
|
buff_idx = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user