Skip to content
Snippets Groups Projects
Select Git revision
  • 8b16c4c27421c439c7678c5e9fc210ae9ab86c7c
  • master default protected
  • compose
  • dockerservices
  • simpleservices
  • hotsource
6 results

__init__.py

Blame
  • Forked from COM3014 / microservices
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    free_store_contents.c 3.91 KiB
    #include "../binary_c.h"
    No_empty_translation_unit_warning;
    
    
    #define Store_free(P) Safe_free(store->P);
    
    void free_store_contents(struct store_t * RESTRICT const store)
    {
        /*
         * Free the content in the store.
         * See also build_store_contents.c
         *
         * Note:
         * NOTHING in here can depend on the current stardata.
         * You will NOT have access to stardata here.
         */
        if(store)
        {
    #ifdef NUCSYN
            nucsyn_free_store_contents(store);
    #endif
    
            int kt;
            for(kt=0;kt<COLLISION_MATRIX_SIZE;kt++)
            {
                Store_free(collision_matrix[kt]);
            }
    
            Delete_data_table(store->jaschek_jaschek_dwarf);
            Delete_data_table(store->jaschek_jaschek_giant);
            Delete_data_table(store->jaschek_jaschek_supergiant);
    
    #ifdef USE_2012_MAIN_SEQUENCE_LIFETIMES_TABLE
            Delete_data_table(store->massive_MS_lifetimes);
    #endif
    #ifdef MAIN_SEQUENCE_STRIP
            Delete_data_table(store->MS_strip);
    #endif
    #ifdef STELLAR_COLOURS
            Delete_data_table(store->Eldridge2012_colours);
            Delete_data_table(store->carrasco2014_table3);
            Delete_data_table(store->carrasco2014_table4);
            Delete_data_table(store->carrasco2014_table5);
            Delete_data_table(store->carrasco2014_cooling_table3);
            Delete_data_table(store->carrasco2014_cooling_table4);
            Delete_data_table(store->carrasco2014_cooling_table5);
            binary_magnitudes_free_memory(store);
    #endif // STELLAR_COLOURS
    #ifdef COMENV_WANG_2016
            Store_free(tableh1);
            Store_free(tableh2);
            Store_free(tableh3);
            Store_free(tableb1);
            Store_free(tableb2);
            Store_free(tableb3);
            Store_free(tableg1);
            Store_free(tableg2);
            Store_free(tableg3);
            Store_free(comenv_maxR_table->data);
            Delete_data_table(store->comenv_maxR_table);
    #endif
    #ifdef COMENV_POLYTROPES
            Delete_data_table(store->comenv_polytrope_2d);
            Store_free(comenv_polytrope_3d);
            Delete_data_table(store->comenv_polytrope_rsms);
    #endif
            Delete_data_table(store->comenv_Klencki_2020);
            Delete_data_table(store->Karakas_ncal);
    #ifdef OPACITY_ALGORITHMS
    #  ifdef OPACITY_ENABLE_ALGORITHM_FERGUSON_OPAL
            Store_free(opacity_ferguson_opal);
    #  endif
    #  ifdef OPACITY_ENABLE_ALGORITHM_STARS
            Store_free(opacity_STARS);
    #  endif
    #endif
            Store_free(miller_bertolami);
            Store_free(miller_bertolami_coeffs_L);
            Store_free(miller_bertolami_coeffs_R);
            Delete_data_table(store->Karakas2002_lumfunc);
            Delete_data_table(store->Karakas2002_radius);
    #ifdef MINT
            MINT_free_store(store);
    #endif
    
            free_pulsator_store(store);
    
    
    #ifdef __HAVE_LIBPTHREAD__
    #define Mutex_error_string(X)                   \
            (X) == EINVAL ? "EINVAL" :              \
                (X) == EBUSY ? "EBUSY" :            \
                (X) == EAGAIN ? "EAGAIN" :          \
                (X) == EPERM ? "EPERM" :            \
                (X) == EDEADLK ? "EDEADLK"  :       \
                "unknown"
    
            /*
             * Make mutexes for later locking
             */
            for(size_t i=0; i<BINARY_C_MUTEX_NUMBER; i++)
            {
                const int unlock_status = pthread_mutex_unlock(&store->pthread_mutexes[i]);
                if(unlock_status != 0)
                {
                    fprintf(stderr,"\n mutex %zu unlock failed with error %d %s\n",
                            i,
                            unlock_status,
                            Mutex_error_string(unlock_status));
                }
                const int destroy_status = pthread_mutex_destroy(&store->pthread_mutexes[i]);
                if(destroy_status != 0)
                {
                    fprintf(stderr,
                            "\n failed to destroy pthread mutex %zu error %d %s: may cause problems\n",
                            i,
                            destroy_status,
                            Mutex_error_string(destroy_status));
                }
            }
    #endif//__HAVE_LIBPTHREAD__
        }
    }