From 83f13018b65ff735322065b2dc6b8a350defab82 Mon Sep 17 00:00:00 2001 From: Guillaume Sylvand <guillaume.sylvand@airbus.com> Date: Wed, 12 Oct 2016 12:08:53 +0000 Subject: [PATCH] morse_desc_init_user(): If one of the function get_* is NULL, we switch back to the default, like in morse_desc_init() This allows to change only 1 or 2 of the 3 functions, and keep the other unchanged. For example, in OOC, only the 1st is modified (to always return NULL). --- control/descriptor.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/control/descriptor.c b/control/descriptor.c index 3cf74f6e9..70472522f 100644 --- a/control/descriptor.c +++ b/control/descriptor.c @@ -71,9 +71,10 @@ MORSE_desc_t morse_desc_init_user(MORSE_enum dtyp, int mb, int nb, int bsiz, int (*get_rankof)( const MORSE_desc_t*, int, int )) { MORSE_desc_t desc; - desc.get_blkaddr = get_blkaddr; - desc.get_blkldd = get_blkldd; - desc.get_rankof = get_rankof; + // If one of the function get_* is NULL, we switch back to the default, like in morse_desc_init() + desc.get_blkaddr = get_blkaddr ? get_blkaddr : morse_getaddr_ccrb; + desc.get_blkldd = get_blkldd ? get_blkldd : morse_getblkldd_ccrb; + desc.get_rankof = get_rankof ? get_rankof : morse_getrankof_2d; // Matrix properties desc.dtyp = dtyp; // seems useless -- GitLab