-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2129 from ghaerr/malloc
[libc] Create debug version of malloc, fix near->far malloc conversion bug
- Loading branch information
Showing
8 changed files
with
123 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#if VERBOSE | ||
#include <stdarg.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
int __debug_level = 1; | ||
|
||
/* | ||
* Very tiny printf to stderr. | ||
* Supports: | ||
* %u unsigned int | ||
*/ | ||
int __dprintf(const char *fmt, ...) | ||
{ | ||
unsigned int n = 0; | ||
char *p; | ||
va_list va; | ||
char b[128]; | ||
|
||
if (__debug_level == 0) | ||
return 0; | ||
va_start(va, fmt); | ||
for (; *fmt; fmt++) { | ||
if (*fmt == '%') { | ||
switch (*++fmt) { | ||
case 'u': | ||
p = uitoa(va_arg(va, unsigned int)); | ||
while (*p && n < sizeof(b)) | ||
b[n++] = *p++; | ||
break; | ||
} | ||
continue; | ||
} else { | ||
if (n < sizeof(b)) | ||
b[n++] = *fmt; | ||
} | ||
} | ||
va_end(va); | ||
return write(2, b, n); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.