supercasiobros/src/base.c

51 lines
800 B
C

#include <base.h>
#include <gint/std/stdlib.h>
#include <liblog.h>
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;
}
int abs(const int x)
{
if (x>0) return x;
else return -x;
}
static int ram_used=0;
void* mallocProf(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);
}
else ll_sendp(LEVEL_CRITICAL, "\n[std] malloc %d FAILED", size);
return p;
}
void freeProf(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);
}