Project

General

Profile

Revision 373

more changes

View differences:

proj/src/project/include/proj_func.h
15 15
//#include <stdint.h>
16 16

  
17 17
/**
18
 * @brief Cleans up all memory, unsubscribes interrupts.
19
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
20
 * @see {_ERRORS_H_::errors}
21
 */
22
int cleanup(void);
23

  
24
/**
25 18
 * @brief Update key presses.
26 19
 */
27 20
void update_key_presses(void);
proj/src/project/src/proj.c
77 77
        bsp_nothing   = get_nothing  (); if(bsp_nothing   == NULL) printf("Failed to get nothing\n");
78 78
        bsp_bullet    = get_bullet   (); if(bsp_bullet    == NULL) printf("Failed to get bullet\n");
79 79
        map1          = get_map1     (); if(map1          == NULL) printf("Failed to get map1\n");
80

  
81 80
        sp_crosshair = sprite_ctor(bsp_crosshair); if(sp_crosshair == NULL) printf("Failed to get crosshair sprite\n");
82 81
    }
83 82

  
......
148 147
        }
149 148
    }
150 149

  
150
    if ((r = unsubscribe_all()))
151
        printf("%s: failed to unsubscribe drivers.\n", __func__);
152
    if ((r = graph_cleanup()))
153
        printf("%s: graph cleanup failed\n", __func__);
154

  
151 155
    text_dtor(title);
152 156
    menu_dtor(main_menu);
153 157

  
154 158
    basic_sprite_dtor      (bsp_crosshair); bsp_crosshair = NULL;
155 159
    basic_sprite_dtor      (bsp_shooter  ); bsp_shooter   = NULL;
156 160
    basic_sprite_dtor      (bsp_zombie   ); bsp_zombie    = NULL;
157
    sprite_dtor            (sp_crosshair ); sp_crosshair  = NULL;
158 161
    basic_sprite_dtor      (bsp_pistol   ); bsp_pistol    = NULL;
159 162
    basic_sprite_dtor      (bsp_nothing  ); bsp_nothing   = NULL;
163
    basic_sprite_dtor      (bsp_bullet   ); bsp_bullet    = NULL;
160 164
    map_dtor               (map1         ); map1          = NULL;
161
    font_free();
165
    sprite_dtor            (sp_crosshair ); sp_crosshair  = NULL;
162 166

  
163
    // Unsubscribe interrupts
164
    if (unsubscribe_all()) {
165
        if (cleanup())
166
        printf("%s: failed to cleanup.\n", __func__);
167
        return 1;
168
    }
169 167

  
170
    if (cleanup()) {
171
        printf("%s: failed to cleanup.\n", __func__);
172
        return 1;
173
    }
174 168

  
175
    return 0;
169
    font_free();
170

  
171
    return r;
176 172
}
177 173

  
178 174
static host_info_t     *host_info   = NULL;
proj/src/project/src/proj_func.c
9 9

  
10 10
#include <math.h>
11 11

  
12
int cleanup(void) {
13
    int r = SUCCESS;
14
    if ((r = unsubscribe_all()))
15
        printf("%s: failed to unsubscribe drivers.\n", __func__);
16
    if ((r = graph_cleanup()))
17
        printf("%s: graph cleanup failed\n", __func__);
18

  
19
    return r;
20
}
21

  
22 12
static keys_t key_presses;
23 13
void update_key_presses(void) {
24 14
    if (keyboard_get_size() == 1) {

Also available in: Unified diff