EMMA Coverage Report (generated Mon Mar 20 21:34:30 PST 2006)
[all classes][com.moesol.bindings.platform_sdk.component_services]

COVERAGE SUMMARY FOR SOURCE FILE [MallocSpy.java]

nameclass, %method, %block, %line, %
MallocSpy.java100% (1/1)92%  (12/13)96%  (77/80)94%  (22.7/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MallocSpy100% (1/1)92%  (12/13)96%  (77/80)94%  (22.7/24)
instance (): MallocSpy 0%   (0/1)0%   (0/2)0%   (0/1)
register (): void 100% (1/1)90%  (9/10)92%  (3.7/4)
<static initializer> 100% (1/1)100% (5/5)100% (2/2)
CoTaskMemAlloc (int): int 100% (1/1)100% (3/3)100% (1/1)
CoTaskMemDidAlloc (int): boolean 100% (1/1)100% (3/3)100% (1/1)
CoTaskMemFree (int): void 100% (1/1)100% (3/3)100% (2/2)
CoTaskMemGetSize (int): int 100% (1/1)100% (3/3)100% (1/1)
CoTaskMemRealloc (int, int): int 100% (1/1)100% (4/4)100% (1/1)
LogAlloc (int, int): void 100% (1/1)100% (19/19)100% (3/3)
LogFree (int, int): void 100% (1/1)100% (19/19)100% (3/3)
MallocSpy (): void 100% (1/1)100% (3/3)100% (1/1)
getAllocatedBytes (): int 100% (1/1)100% (2/2)100% (1/1)
unregister (): void 100% (1/1)100% (4/4)100% (3/3)

1/*
2 * $Id: MallocSpy.java,v 1.2 2005/11/16 21:42:18 hastings Exp $
3 *
4 * (c) Copyright, Moebius Solutions, Inc., 2004
5 *
6 *                       All Rights Reserved
7 *
8 * This material may be reproduced by or for the U. S. Government
9 * pursuant to the copyright license under the clause at
10 * DFARS 252.227-7014 (OCT 2001).
11 */
12 
13package com.moesol.bindings.platform_sdk.component_services;
14 
15import com.moesol.bindings.NativeLibraryLoader;
16 
17public class MallocSpy {
18        static {
19                NativeLibraryLoader.loadLibrary("com_moesol_bindings");
20        }
21    
22    private MallocSpy() { }
23    public static void register() {
24        if (s_instance != null) { return; }
25        s_instance = new MallocSpy();
26        JNI_register(s_instance);
27    }
28    public static MallocSpy instance() {
29        return s_instance;
30    }
31    public static void unregister() {
32        s_instance = null;
33        JNI_unregister();
34    }
35    public static int getAllocatedBytes() {
36        return s_allocated_bytes;
37    }
38    /** Called from JNI */
39    void LogAlloc(int id, int size) {
40        System.out.println("alloc: " + id + "," + size);
41        s_allocated_bytes += size;
42    }
43    /** Called from JNI */
44    void LogFree(int id, int size) {
45        System.out.println("free: " + id + "," + size);
46        s_allocated_bytes -= size;
47    }
48    
49    /** Exposed for unit test */
50    /* package */ static int CoTaskMemAlloc(int cb) {
51        return JNI_CoTaskMemAlloc(cb);
52    }
53    /** Exposed for unit test */
54    /* package */ static void CoTaskMemFree(int ptr) {
55        JNI_CoTaskMemFree(ptr);
56    }
57    /** Exposed for unit test */
58    /* package */ static int CoTaskMemRealloc(int ptr, int cb) {
59        return JNI_CoTaskMemRealloc(ptr, cb);
60    }
61    /** Exposed for unit test */
62    /* package */ static int CoTaskMemGetSize(int ptr) {
63        return JNI_CoTaskMemGetSize(ptr);
64    }
65    /** Exposed for unit test */
66    /* package */ static boolean CoTaskMemDidAlloc(int ptr) {
67        return JNI_CoTaskMemDidAlloc(ptr);
68    }
69    
70    private static native void JNI_register(MallocSpy instance);
71    private static native void JNI_unregister();
72    private static native int JNI_CoTaskMemAlloc(int cb);
73    private static native void JNI_CoTaskMemFree(int ptr);
74    private static native int JNI_CoTaskMemRealloc(int ptr, int cb);
75    private static native int JNI_CoTaskMemGetSize(int ptr);
76    private static native boolean JNI_CoTaskMemDidAlloc(int ptr);
77 
78    //
79    // State
80    //
81 
82    private static int s_allocated_bytes;
83    private static MallocSpy s_instance = null;
84}

[all classes][com.moesol.bindings.platform_sdk.component_services]
EMMA 2.0.5312 (C) Vladimir Roubtsov