2020-01-29 14:34:57 +01:00
|
|
|
#include <base.h>
|
2020-02-03 11:12:54 +01:00
|
|
|
#include <gint/std/stdlib.h>
|
|
|
|
#include <liblog.h>
|
2020-01-29 14:34:57 +01:00
|
|
|
|
|
|
|
int max(const int x, const int y)
|
|
|
|
{
|
|
|
|
return (x<y?y:x);
|
|
|
|
}
|
|
|
|
|
|
|
|
int min(const int x, const int y)
|
|
|
|
{
|
|
|
|
return (x>y?y:x);
|
|
|
|
}
|
|
|
|
|
|
|
|
int sgn(const int x)
|
|
|
|
{
|
|
|
|
if (x>0)
|
|
|
|
return 1;
|
|
|
|
else if (x<0)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 0;
|
2020-02-03 11:12:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ram_used=0;
|
|
|
|
|
|
|
|
void* malloc_prof(int size)
|
|
|
|
{
|
|
|
|
void* p=malloc(size);
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
ll_sendp(LEVEL_INFO, "\n[std] malloc %d OK", size);
|
|
|
|
ram_used++;
|
|
|
|
ll_sendp(LEVEL_INFO, "\n[std] number of zones %d", ram_used);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
ll_sendp(LEVEL_CRITICAL, "\n[std] malloc %d FAILED", size);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void free_prof(void * p)
|
|
|
|
{
|
|
|
|
free(p);
|
|
|
|
ll_sendp(LEVEL_INFO, "\n[std] free called");
|
|
|
|
ram_used--;
|
|
|
|
ll_sendp(LEVEL_INFO, "\n[std] number of zones %d", ram_used);
|
2020-01-29 14:34:57 +01:00
|
|
|
}
|