libc.obj: small fixes
This commit is contained in:
@@ -4,11 +4,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//#include "format_print.h"
|
||||
// #include "format_print.h"
|
||||
|
||||
int printf(const char *format, ...)
|
||||
int printf(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
return vprintf(format, arg);
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
int ret = vprintf(format, arg);
|
||||
va_end(arg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
void* calloc(size_t num, size_t size)
|
||||
{
|
||||
void* ptr = malloc(num * size); // malloc сам в __errno насрет, если надо будет
|
||||
memset(ptr, 0, num * size);
|
||||
void* ptr = malloc(num * size);
|
||||
if (ptr) {
|
||||
memset(ptr, 0, num * size);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
char* strdup(const char* str)
|
||||
{
|
||||
char* buf = malloc(strlen(str) + 1);
|
||||
buf[strlen(str)] = '\0';
|
||||
strcpy(buf, str);
|
||||
if (buf) {
|
||||
buf[strlen(str)] = '\0';
|
||||
strcpy(buf, str);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
Reference in New Issue
Block a user