Improved allocation failure reporting

Now it reports file and line number of the function too.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2018-12-20 14:13:14 +00:00
parent 6f0daf8076
commit 1ea611c90e
4 changed files with 59 additions and 9 deletions

View File

@@ -11,6 +11,25 @@ char *
mstrjoin3(const char *src1, const char *src2, const char *src3);
void mstrextend(char **psrc1, const char *src2);
static inline int uitostr(unsigned int n, char *buf) {
int ret = 0;
unsigned int tmp = n;
while (tmp > 0) {
tmp /= 10;
ret++;
}
if (ret == 0)
ret = 1;
int pos = ret;
while (pos--) {
buf[pos] = n%10 + '0';
n /= 10;
}
return ret;
}
static inline const char *
skip_space_const(const char *src) {
if (!src)