X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Ffunc_template.h;h=769debb2a96e84c350da8c118a6e0067885bd7dc;hb=c9244d0b6ce2dae9311dc5f6a49ee774b1d2f98a;hp=c25fb11f52a37a10bcba235ca264da7184c4fede;hpb=a32bee3a7c3792af75f2772dd6501fb9429ca749;p=gedcom-parse.git diff --git a/gom/func_template.h b/gom/func_template.h index c25fb11..769debb 100644 --- a/gom/func_template.h +++ b/gom/func_template.h @@ -97,6 +97,39 @@ (FIRSTVAL)->previous = VAL->previous; \ } +#define MOVE_CHAIN_ELT(STRUCTTYPE, DIR, FIRSTVAL, VAL) \ + { \ + struct STRUCTTYPE *first, *second; \ + if (DIR == MOVE_UP) { \ + first = VAL->previous; \ + second = VAL; \ + } \ + else { \ + first = VAL; \ + second = VAL->next; \ + } \ + if (second && (second != FIRSTVAL)) { \ + if (first != FIRSTVAL) \ + first->previous->next = second; \ + else \ + FIRSTVAL = second; \ + \ + if (second->next) \ + second->next->previous = first; \ + else \ + (FIRSTVAL)->previous = first; \ + \ + first->next = second->next; \ + second->next = first; \ + \ + second->previous = first->previous; \ + first->previous = second; \ + } \ + else { \ + gom_move_error(#STRUCTTYPE); \ + } \ + } + #define MAKE_CHAIN_ELT(STRUCTTYPE, FIRSTVAL, VAL) \ { \ VAL = (struct STRUCTTYPE*) malloc(sizeof(struct STRUCTTYPE)); \