_malloc_memdsp.c
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
=============================================================================
Copyright (C) 1997-1999 NINTENDO Co.,Ltd.
$RCSfile: _malloc_memdsp.c,v $
$Revision: 1.1.1.1 $
$Date: 2002/10/30 02:07:09 $
-----------------------------------------------------------------------------
*/
#include <ultra64.h>
#include "string.h"
#include "malloc.h"
#include "_malloc.h"
int sprintf(char *s, const char *format, ...);
int _malloc_memdsp(void *ptr, unsigned char *s, int size)
{
int a;
struct mallocST *malloc_st_ptr;
unsigned int *maxptr;
malloc_st_ptr = ptr;
maxptr = ptr;
maxptr += (malloc_st_ptr->allsize)/sizeof(unsigned int *);
a = 0;
while(1) {
if (a/2 == size/2) break;
sprintf(&s[(a++)*60], "%08x:%08x-%08x", (unsigned int)(malloc_st_ptr),
(unsigned int)(malloc_st_ptr)+MALLOC_HEADSIZE,
(unsigned int)(malloc_st_ptr)+MALLOC_HEADSIZE
+malloc_st_ptr->size-1);
if( !malloc_st_ptr->flag ){
if (malloc_st_ptr->size){
sprintf(&s[(a++)*60], " (%08x)[%08x] FREE",
malloc_st_ptr->size, malloc_st_ptr->next);
}else{
sprintf(&s[(a++)*60], " (%08x)[%08x] ALIN",
malloc_st_ptr->size, malloc_st_ptr->next);
}
}else{
sprintf(&s[(a++)*60], " (%08x)[%08x] USE",
malloc_st_ptr->size, malloc_st_ptr->next);
}
if (!malloc_st_ptr->next) break;
if ((malloc_st_ptr->next < (unsigned int *)ptr)
|| (malloc_st_ptr->next > maxptr)
|| ((int)malloc_st_ptr->next & 3)) {
sprintf(&s[(a++)*60],
"malloc_memdsp error:%08x over area %08x-%08x",
malloc_st_ptr->next, ptr, maxptr);
sprintf(&s[(a++)*60], "");
return a;
}
malloc_st_ptr = (struct mallocST *)malloc_st_ptr->next;
}
return a;
}