Example #1
0
static void
_bu_close_files()
{
    struct _bu_tf_list *popped;
    if (!_bu_tf) {
	return;
    }

    /* close all files, free their nodes, and unlink */
    while (BU_LIST_WHILE(popped, _bu_tf_list, &(_bu_tf->l))) {
	BU_LIST_DEQUEUE(&(popped->l));
	if (popped) {
	    if (popped->fd != -1) {
		close(popped->fd);
		popped->fd = -1;
	    }
	    if (BU_VLS_IS_INITIALIZED(&popped->fn) && bu_vls_addr(&popped->fn)) {
		unlink(bu_vls_addr(&popped->fn));
		bu_vls_free(&popped->fn);
	    }
	    bu_free(popped, "free bu_temp_file node");
	}
    }

    /* free the head */
    if (_bu_tf->fd != -1) {
	close(_bu_tf->fd);
	_bu_tf->fd = -1;
    }
    if (BU_VLS_IS_INITIALIZED(&_bu_tf->fn) && bu_vls_addr(&_bu_tf->fn)) {
	unlink(bu_vls_addr(&_bu_tf->fn));
	bu_vls_free(&_bu_tf->fn);
    }
    bu_free(_bu_tf, "free bu_temp_file head");
}
Example #2
0
/**
 * Free the storage associated with the rt_db_internal version of this
 * solid.
 */
void
rt_revolve_ifree(struct rt_db_internal *ip)
{
    struct rt_revolve_internal *revolve_ip;

    RT_CK_DB_INTERNAL(ip);

    revolve_ip = (struct rt_revolve_internal *)ip->idb_ptr;
    RT_REVOLVE_CK_MAGIC(revolve_ip);
    revolve_ip->magic = 0;			/* sanity */

    if (BU_VLS_IS_INITIALIZED(&revolve_ip->sketch_name))
	bu_vls_free(&revolve_ip->sketch_name);
    else
	bu_log("Freeing bogus revolve, VLS string not initialized\n");

    bu_free((char *)revolve_ip, "revolve ifree");
    ip->idb_ptr = ((void *)0);	/* sanity */
}