mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-04 22:30:09 +00:00
Add more memory log
This commit is contained in:
parent
80a9497afd
commit
118d62d42d
657 changed files with 4179 additions and 3131 deletions
|
|
@ -120,7 +120,7 @@ char *ogs_slprintf(char *str, char *last, const char *format, ...)
|
|||
return r;
|
||||
}
|
||||
|
||||
char *ogs_strdup_debug(const char *s, const char *file_line)
|
||||
char *ogs_strdup_debug(const char *s, const char *file_line, bool abort)
|
||||
{
|
||||
char *res;
|
||||
size_t len;
|
||||
|
|
@ -129,11 +129,13 @@ char *ogs_strdup_debug(const char *s, const char *file_line)
|
|||
return NULL;
|
||||
|
||||
len = strlen(s) + 1;
|
||||
res = ogs_memdup_debug(s, len, file_line);
|
||||
res = ogs_memdup_debug(s, len, file_line, abort);
|
||||
ogs_expect_or_return_val(res, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
char *ogs_strndup_debug(const char *s, size_t n, const char *file_line)
|
||||
char *ogs_strndup_debug(
|
||||
const char *s, size_t n, const char *file_line, bool abort)
|
||||
{
|
||||
char *res;
|
||||
const char *end;
|
||||
|
|
@ -144,20 +146,23 @@ char *ogs_strndup_debug(const char *s, size_t n, const char *file_line)
|
|||
end = memchr(s, '\0', n);
|
||||
if (end != NULL)
|
||||
n = end - s;
|
||||
res = ogs_malloc_debug(n + 1, file_line);
|
||||
res = ogs_malloc_debug(n + 1, file_line, abort);
|
||||
ogs_expect_or_return_val(res, res);
|
||||
memcpy(res, s, n);
|
||||
res[n] = '\0';
|
||||
return res;
|
||||
}
|
||||
|
||||
void *ogs_memdup_debug(const void *m, size_t n, const char *file_line)
|
||||
void *ogs_memdup_debug(
|
||||
const void *m, size_t n, const char *file_line, bool abort)
|
||||
{
|
||||
void *res;
|
||||
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
|
||||
res = ogs_malloc_debug(n, file_line);
|
||||
res = ogs_malloc_debug(n, file_line, abort);
|
||||
ogs_expect_or_return_val(res, res);
|
||||
memcpy(res, m, n);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -195,7 +200,8 @@ char *ogs_cpystrn(char *dst, const char *src, size_t dst_size)
|
|||
*
|
||||
* https://github.com/babelouest/orcania.git
|
||||
*/
|
||||
char *ogs_msprintf_debug(const char *file_line, const char *message, ...)
|
||||
char *ogs_msprintf_debug(
|
||||
const char *file_line, bool abort, const char *message, ...)
|
||||
{
|
||||
va_list argp, argp_cpy;
|
||||
size_t out_len = 0;
|
||||
|
|
@ -206,7 +212,7 @@ char *ogs_msprintf_debug(const char *file_line, const char *message, ...)
|
|||
in some architectures,
|
||||
vsnprintf can modify argp */
|
||||
out_len = vsnprintf(NULL, 0, message, argp);
|
||||
out = ogs_malloc_debug(out_len + sizeof(char), file_line);
|
||||
out = ogs_malloc_debug(out_len + sizeof(char), file_line, abort);
|
||||
if (out == NULL) {
|
||||
va_end(argp);
|
||||
va_end(argp_cpy);
|
||||
|
|
@ -220,7 +226,8 @@ char *ogs_msprintf_debug(const char *file_line, const char *message, ...)
|
|||
}
|
||||
|
||||
char *ogs_mstrcatf_debug(
|
||||
char *source, const char *file_line, const char *message, ...)
|
||||
char *source, const char *file_line, bool abort,
|
||||
const char *message, ...)
|
||||
{
|
||||
va_list argp, argp_cpy;
|
||||
char *out = NULL, *message_formatted = NULL;
|
||||
|
|
@ -238,7 +245,7 @@ char *ogs_mstrcatf_debug(
|
|||
vsnprintf(message_formatted,
|
||||
(message_formatted_len+sizeof(char)), message, argp_cpy);
|
||||
out = ogs_msprintf_debug(
|
||||
file_line, "%s%s", source, message_formatted);
|
||||
file_line, abort, "%s%s", source, message_formatted);
|
||||
ogs_free(message_formatted);
|
||||
ogs_free(source);
|
||||
}
|
||||
|
|
@ -250,7 +257,7 @@ char *ogs_mstrcatf_debug(
|
|||
in some architectures,
|
||||
vsnprintf can modify argp */
|
||||
out_len = vsnprintf(NULL, 0, message, argp);
|
||||
out = ogs_malloc_debug(out_len+sizeof(char), file_line);
|
||||
out = ogs_malloc_debug(out_len+sizeof(char), file_line, abort);
|
||||
if (out != NULL) {
|
||||
vsnprintf(out, (out_len+sizeof(char)), message, argp_cpy);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue