Ejemplo n.º 1
0
/**
 * Deallocate a \ref grid_viewport_t.
 *
 * \param vp A viewport.
 */
void
free_grid_viewport(grid_viewport_t *vp) {
    if (vp->x)
        free_unit(vp->x);
    if (vp->y)
        free_unit(vp->y);
    if (vp->w)
        free_unit(vp->w);
    if (vp->h)
        free_unit(vp->h);

    free(vp);
}
Ejemplo n.º 2
0
void gen_cleanup(void) {
	if (active_gens == NULL) return;
	while (active_gens->dlink != NULL)
		unlink_gen((GEN *)active_gens->dlink);
	free_unit(active_gens);
	active_gens = NULL;
	return;
	}
Ejemplo n.º 3
0
void feeds_cleanup(lua_State *lstate) {
	if (feeds == NULL) return;
	while (feeds->dlink != NULL)
		unlink_feed((FEED *)feeds->dlink);
	free_unit(feeds);
	feeds = NULL;
	return;
	}
Ejemplo n.º 4
0
Archivo: region.c Proyecto: stm2/server
void free_region(region * r)
{
    if (last == r)
        last = NULL;
    free(r->display);
    if (r->land)
        free_land(r->land);

    if (r->msgs) {
        free_messagelist(r->msgs->begin);
        free(r->msgs);
        r->msgs = 0;
    }

    while (r->individual_messages) {
        struct individual_message *msg = r->individual_messages;
        r->individual_messages = msg->next;
        if (msg->msgs) {
            free_messagelist(msg->msgs->begin);
            free(msg->msgs);
        }
        free(msg);
    }

    while (r->attribs)
        a_remove(&r->attribs, r->attribs);
    while (r->resources) {
        rawmaterial *res = r->resources;
        r->resources = res->next;
        free(res);
    }

    while (r->units) {
        unit *u = r->units;
        r->units = u->next;
        uunhash(u);
        free_unit(u);
        free(u);
    }

    while (r->buildings) {
        building *b = r->buildings;
        assert(b->region == r);
        r->buildings = b->next;
        bunhash(b);                 /* must be done here, because remove_building does it, and wasn't called */
        free_building(b);
    }

    while (r->ships) {
        ship *s = r->ships;
        assert(s->region == r);
        r->ships = s->next;
        sunhash(s);
        free_ship(s);
    }

    free(r);
}
Ejemplo n.º 5
0
void free_units(void)
{
  while (deleted_units) {
    unit *u = deleted_units;
    deleted_units = deleted_units->next;
    free_unit(u);
    free(u);
  }
}
Ejemplo n.º 6
0
int main(void)
{
    unit_t *p = alloc_unit();

    printf("number: %d\nmsg: %s\n", p->number, p->msg);
    free_unit(p);
    p = NULL;

    return 0;
}
Ejemplo n.º 7
0
void stop_construct(int unit_id)
{
    Unit * unit = UNIT(unit_id);

    if (unit->command.type != COMMAND_CONSTRUCT)
        return;

    Cell * cell = CELL(unit->command.x, unit->command.y);
    if (cell->unit != NO_UNIT)
        free_unit(cell->unit);

    unit->command.type = COMMAND_NONE;
    unit->moving = false;
}
Ejemplo n.º 8
0
/**
 * @brief Permite liberar una región de memoria.
 * @param start_addr Dirección de memoria del inicio de la región a liberar
 * @param length Tamaño de la región a liberar
  @verbatim
  Verifica si la direccion que recibe es menor a la direccion del
  kernel o no, de ser asi sale sin realizar ninguna accion, caso
  contrario se convierte a una direccion lineal para posteriormente
  colocarla en el mapa de bits como una region disponible.
 @endverbatim*/
void free_region(char * start_addr, unsigned int length) {
	 unsigned int start;
	 unsigned int end;

	 start = round_down_to_memory_unit((unsigned int)start_addr);

	 if (start < allowed_free_start) {return;}

	 end = start + length;

	 for (; start < end; start += MEMORY_UNIT_SIZE) {
		 free_unit((char*)start);
	 }

	 /* Almacenar el inicio de la región liberada para una próxima asignación */
	 next_free_unit = (unsigned int)start_addr / MEMORY_UNIT_SIZE;
 }
Ejemplo n.º 9
0
void free_region(region *r) {
    region **bucket;

    bucket = &regionhash[r->uid & RHASHMASK];
    while (*bucket!=r) {
        bucket = &(*bucket)->nexthash_;
    }
    *bucket = r->nexthash_;
    free(r->name_);
    while (r->units) {
        unit *u = r->units;
        r->units = u->next;
        free_unit(u);
    }
    ql_foreach(r->ships, (ql_cb)free_ship);
    ql_free(r->ships);
    r->ships = 0;
    ql_foreach(r->buildings, (ql_cb)free_building);
    ql_free(r->buildings);
    r->buildings = 0;
    free(r);
}