Project

General

Profile

Revision 155

added cleanup

View differences:

proj/Makefile
1 1
PROG=proj
2 2

  
3
SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c
3
SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c
4 4

  
5 5
CPPFLAGS += -pedantic -D __LCOM_OPTIMIZED_
6 6

  
proj/proj.c
19 19
#include "mouse.h"
20 20
#include "utils.h"
21 21
#include "interrupts_func.h"
22
#include "proj_func.h"
22 23

  
23 24
int main(int argc, char* argv[]) {
24 25

  
......
39 40

  
40 41
    if (vbe_get_mode_information(INDEXED_1024_768)) {
41 42
        printf("%s: failed to get information for mode %x.\n", __func__, INDEXED_1024_768);
42
        if (vg_exit())
43
            printf("%s: vg_exit failed to exit to text mode.\n", __func__);
43
        if (cleanup())
44
            printf("%s: failed to cleanup.\n", __func__);
44 45
        return 1;
45 46
    }
46 47

  
......
48 49

  
49 50
    if (set_graphics_mode(INDEXED_1024_768)) {
50 51
        printf("%s: failed to set graphic mode %x.\n", __func__, INDEXED_1024_768);
51
        if (vg_exit()) printf("%s: vg_exit failed to exit to text mode.\n", __func__);
52
        if (free_memory_map()) {
53
            printf("%s: lm_free failed\n", __func__);
54
        }
52
        if (cleanup())
53
            printf("%s: failed to cleanup.\n", __func__);
55 54
        return 1;
56 55
    };
57 56

  
......
61 60
    message msg;
62 61

  
63 62
    /// subscribe interrupts
64
    if (subscribe_all()) return 1;
63
    if (subscribe_all()) {
64
        if (cleanup())
65
            printf("%s: failed to cleanup.\n", __func__);
66
        return 1;
67
    }
65 68

  
66 69
    /// cycle
67 70
    int good = 1;
......
90 93
    }
91 94

  
92 95
    // Unsubscribe interrupts
93
    if (unsubscribe_all()) return 1;
94

  
95

  
96
    if (vg_exit()) {
97
        printf("%s: vg_exit failed to exit to text mode.\n", __func__);
98
        if (free_memory_map()) printf("%s: lm_free failed\n", __func__);
96
    if (unsubscribe_all()) {
97
        if (cleanup())
98
            printf("%s: failed to cleanup.\n", __func__);
99 99
        return 1;
100 100
    }
101 101

  
102
    if (free_memory_map()) {
103
        printf("%s: lm_free failed\n", __func__);
102

  
103
    if (cleanup()) {
104
        printf("%s: failed to cleanup.\n", __func__);
104 105
        return 1;
105 106
    }
106 107

  
......
109 110
        hello
110 111
    #endif
111 112

  
112

  
113 113
    return 0;
114

  
115
    return 0;
116 114
}

Also available in: Unified diff