Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
mem_alloc.h File Reference
#include "system/macros.h"
#include <glib.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
+ Include dependency graph for mem_alloc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DT_IS_ALIGNED(x)   __builtin_assume_aligned(x, DT_CACHELINE_BYTES)
 
#define DT_CACHELINE_BYTES   64
 
#define DT_CACHELINE_FLOATS   16
 
#define DT_CACHELINE_PIXELS   4
 
#define DT_ALIGNED_ARRAY   __attribute__((aligned(DT_CACHELINE_BYTES)))
 
#define DT_ALIGNED_PIXEL   __attribute__((aligned(16)))
 
#define dt_free(ptr)
 
#define dt_free_align(ptr)
 

Functions

static gboolean dt_is_aligned (const void *pointer, size_t byte_count)
 
static size_t dt_round_size (const size_t size, const size_t alignment)
 
static size_t dt_round_size_sse (const size_t size)
 
static voiddt_alloc_align_internal (size_t size)
 
voiddt_alloc_align (size_t size)
 
static void dt_free_gpointer (gpointer ptr)
 
static void dt_free_align_ptr (void *mem)
 
static voiddt_calloc_align (size_t size)
 
static float * dt_alloc_align_float (size_t pixels)
 
static float * dt_calloc_align_float (size_t pixels)
 
static voiddt_check_sse_aligned (void *pointer)
 
static void memset_zero (void *const buffer, size_t size)
 Set the memory buffer to zero as a pack of unsigned char.
 

Macro Definition Documentation

◆ DT_ALIGNED_ARRAY

#define DT_ALIGNED_ARRAY   __attribute__((aligned(DT_CACHELINE_BYTES)))

Definition at line 60 of file mem_alloc.h.

◆ DT_ALIGNED_PIXEL

#define DT_ALIGNED_PIXEL   __attribute__((aligned(16)))

Definition at line 61 of file mem_alloc.h.

◆ DT_CACHELINE_BYTES

#define DT_CACHELINE_BYTES   64

Definition at line 52 of file mem_alloc.h.

◆ DT_CACHELINE_FLOATS

#define DT_CACHELINE_FLOATS   16

Definition at line 53 of file mem_alloc.h.

◆ DT_CACHELINE_PIXELS

#define DT_CACHELINE_PIXELS   4

Definition at line 54 of file mem_alloc.h.

◆ dt_free

#define dt_free (   ptr)
Value:
if(!IS_NULL_PTR(ptr)) \
{ \
g_free((void *)(ptr)); \
*(void **)(&(ptr)) = NULL; \
}
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition macros.h:65

Definition at line 97 of file mem_alloc.h.

◆ dt_free_align

#define dt_free_align (   ptr)
Value:
if(!IS_NULL_PTR(ptr)) \
{ \
dt_free_align_ptr((void *)(ptr)); \
*(void **)(&(ptr)) = NULL; \
}

Definition at line 122 of file mem_alloc.h.

◆ DT_IS_ALIGNED

#define DT_IS_ALIGNED (   x)    __builtin_assume_aligned(x, DT_CACHELINE_BYTES)

Definition at line 43 of file mem_alloc.h.

Function Documentation

◆ dt_alloc_align()

◆ dt_alloc_align_float()

◆ dt_alloc_align_internal()

static void * dt_alloc_align_internal ( size_t  size)
inlinestatic

Definition at line 80 of file mem_alloc.h.

References DT_CACHELINE_BYTES, dt_round_size(), L, and size.

Referenced by dt_alloc_align().

◆ dt_calloc_align()

static void * dt_calloc_align ( size_t  size)
inlinestatic

◆ dt_calloc_align_float()

static float * dt_calloc_align_float ( size_t  pixels)
inlinestatic

Definition at line 139 of file mem_alloc.h.

References dt_alloc_align(), DT_CACHELINE_BYTES, and L.

◆ dt_check_sse_aligned()

static void * dt_check_sse_aligned ( void pointer)
inlinestatic

Definition at line 145 of file mem_alloc.h.

References DT_CACHELINE_BYTES, dt_is_aligned(), and L.

◆ dt_free_align_ptr()

static void dt_free_align_ptr ( void mem)
inlinestatic

Definition at line 111 of file mem_alloc.h.

References L.

◆ dt_free_gpointer()

static void dt_free_gpointer ( gpointer  ptr)
inlinestatic

Definition at line 104 of file mem_alloc.h.

References L.

Referenced by __attribute__(), _apply_preferences(), _ask_and_delete(), _choose_gpx_callback(), _colorspaces_destroy(), _datetime_undo_data_free(), _dev_auto_apply_presets(), _distort_xtransform(), _draw_paths(), _dt_style_update_iop_order(), _event_dnd_get(), _exif_xmp_read_data(), _exif_xmp_read_data_export(), _film_import1(), _folder_survey_job_run(), _geotag_undo_data_free(), _get_base_value(), _gradient_slider_destroy(), _history_undo_data_free(), _hm_backup_cleanup(), _hm_build_id_set_from_mod_list(), _hm_build_last_history_by_id(), _hm_build_last_history_by_id_from_history(), _hm_build_next_map_from_ids(), _hm_build_override_map(), _hm_build_prev_map_from_ids(), _hm_cached_order_applicable(), _hm_report_build_moved_set(), _hm_report_update_arrows(), _hm_restore_dest_from_backup(), _hm_topo_build_constraint_ids(), _hm_topo_build_id_info_table(), _hm_topo_merge_cleanup(), _hm_topo_resolve_incompatible_constraints(), _ioporder_get_current_order_name(), _metadata_view_update_values(), _pop_undo(), _print_button_clicked(), _refresh_display_track(), _resync_xmp_duplicates(), _save_last_tag_used(), _set_printer(), _setup_selected_images_list(), _styles_init_source_dev(), _styles_prepare_source_dev(), _undo_metadata_free(), _update(), _upgrade_data_schema_step(), _upgrade_library_schema_step(), _view_map_draw_other_locations(), _write_xmp_id(), append_styles(), apply_clicked(), build_global_distortion_map(), cleanup(), clear_search(), delete_clicked(), dt_accels_window(), dt_bauhaus_combobox_from_conf(), dt_bauhaus_widget_set_label(), dt_cleanup(), dt_conf_init(), dt_control_crawler_show_image_list(), dt_control_delete_images_job_run(), dt_control_export_job_run(), dt_control_import_data_free(), dt_dev_cleanup(), dt_dev_history_undo_start_record_locked(), dt_dev_pixelpipe_cache_init(), dt_dev_pixelpipe_cleanup_nodes(), dt_dev_snapshot_capture(), dt_dng_opcode_process_opcode_list_2(), dt_exif_read_blob(), dt_exif_xmp_read(), dt_film_remove_empty(), dt_folder_survey_absorb_new_files(), dt_folder_survey_count_new_files(), dt_folder_survey_init(), dt_get_selected_files(), dt_gui_preferences_enum(), dt_gui_set_themes(), dt_history_get_items_as_string(), dt_hm_batch_state_cleanup(), dt_image_cache_deallocate(), dt_image_read_duplicates(), dt_import_cleanup(), dt_init(), dt_ioppr_change_iop_order(), dt_ioppr_deserialize_iop_order_list(), dt_ioppr_deserialize_text_iop_order_list(), dt_ioppr_get_iop_order_list(), dt_ioppr_rebuild_iop_order_from_modules(), dt_ioppr_set_default_iop_order(), dt_ioppr_update_for_modules(), dt_lib_export_metadata_configuration_dialog(), dt_lib_export_metadata_set_conf(), dt_masks_free_form(), dt_metadata_clear(), dt_metadata_set(), dt_metadata_set_import(), dt_metadata_set_list(), dt_pwstorage_kwallet_get(), dt_pwstorage_libsecret_get(), dt_style_repository_normalize_multi_priority(), dt_styles_create_from_image(), dt_styles_get_item_list_as_string(), dt_styles_save_to_file(), dt_styles_style_data_free(), dt_tag_import(), dt_view_manager_cleanup(), dtgtk_gradient_slider_multivalue_clear_stops(), export_clicked(), finalize_store(), free_chart(), free_labels_list(), free_location(), free_params(), get_query_string(), gui_cleanup(), gui_cleanup(), gui_reset(), import_clicked(), import_preset(), init_presets(), list_match_string(), load_watermarks(), main(), main(), main(), modify_roi_in(), parse_cht(), refresh_watermarks(), run_style_scenarios(), secret_to_attributes(), set_params(), store(), update_profile_list(), and write_image().

◆ dt_is_aligned()

static gboolean dt_is_aligned ( const void pointer,
size_t  byte_count 
)
inlinestatic

Definition at line 63 of file mem_alloc.h.

References L.

Referenced by dt_check_sse_aligned().

◆ dt_round_size()

static size_t dt_round_size ( const size_t  size,
const size_t  alignment 
)
inlinestatic

Definition at line 68 of file mem_alloc.h.

References size.

Referenced by _prepare_resampling_plan(), dt_alloc_align_internal(), and dt_round_size_sse().

◆ dt_round_size_sse()

static size_t dt_round_size_sse ( const size_t  size)
inlinestatic

Definition at line 74 of file mem_alloc.h.

References dt_round_size(), and size.

Referenced by _dt_masks_dynbuf_growto(), fast_eigf_surface_blur(), and fast_surface_blur().

◆ memset_zero()

static void memset_zero ( void *const  buffer,
size_t  size 
)
inlinestatic

Set the memory buffer to zero as a pack of unsigned char.

Parameters
buffervoid buffer
sizesize of the memory stride. NEEDS TO BE A MULTIPLE OF 8.

Definition at line 159 of file mem_alloc.h.

References k, and size.

Referenced by lmmse_demosaic(), process(), and xtrans_markesteijn_interpolate().