util  Diff

Differences From Artifact [5c0572111c]:

To Artifact [ba4baffdd8]:


     1         -#ifndef _ll_delete
     2         -#define _ll_delete free
     3         -#endif
     4         -
     5      1   #ifndef _ll_ffirst
     6      2   #define _ll_ffirst _cat(first_,_ll_rec)
     7      3   #endif
     8      4   
     9      5   #ifndef _ll_flast
    10      6   #define _ll_flast _cat(last_,_ll_rec)
    11      7   #endif
    12      8   
    13      9   #ifndef _ll_fnext
    14     10   #define _ll_fnext _cat(next_,_ll_rec)
    15     11   #endif
    16     12   
           13  +#define _LL_fn(act) _cat(_cat(_ll_ns,_),_cat(_cat(act,_), _ll_rec))
    17     14   #ifndef _ll_dropfn
    18         -#define _ll_dropfn _cat(_cat(_ll_ns,_),_cat(drop_, _ll_rec))
           15  +#define _ll_dropfn _LL_fn(drop)
    19     16   #endif
    20     17   
    21     18   #ifndef _ll_pushfn
    22         -#define _ll_pushfn _cat(_cat(_ll_ns,_),_cat(push_, _ll_rec))
           19  +#define _ll_pushfn _LL_fn(push)
           20  +#endif
           21  +
           22  +#ifndef _ll_newfn
           23  +#define _ll_newfn _LL_fn(new)
           24  +#endif
           25  +
           26  +#ifndef _ll_delete
           27  +#define _ll_delete free
           28  +#	ifdef _ll_impl
           29  +#		include <stdlib.h>
           30  +#	endif
           31  +#endif
           32  +
           33  +#ifdef _ll_impl
           34  +#	define _LL_impl(...) __VA_ARGS__
           35  +#	include "def.h"
           36  +#else
           37  +#	define _LL_impl(...) ;
    23     38   #endif
           39  +
           40  +void _ll_pushfn
           41  +(_ll_box* box, _ll_obj* obj) _LL_impl({
           42  +	if (box -> _ll_flast)
           43  +		box -> _ll_flast -> _ll_fnext = obj;
           44  +	else box -> _ll_ffirst = obj;
           45  +	box -> _ll_flast = obj;
           46  +})
           47  +
           48  +_ll_obj* _ll_newfn
           49  +(_ll_box* box) _LL_impl({
           50  +	_ll_obj* o = calloc(1, sizeof(_ll_obj));
           51  +	_ll_pushfn(box, o);
           52  +	return o;
           53  +})
    24     54   
    25     55   void _ll_dropfn
    26         -(_ll_box* box, _ll_obj* obj) {
           56  +(_ll_box* box, _ll_obj* obj) _LL_impl({
    27     57   	if(box -> _ll_ffirst == obj) {
    28     58   		if(box -> _ll_flast == obj) {
    29     59   			box -> _ll_ffirst = box -> _ll_flast = null;
    30     60   		} else {
    31     61   			box -> _ll_ffirst = obj -> _ll_fnext;
    32     62   		}
    33     63   	} else {
................................................................................
    50     80   				}
    51     81   			}
    52     82   			_fatal("BUG in elt deletion routine");
    53     83   			found2 :;
    54     84   		}
    55     85   	}
    56     86   	_ll_delete (obj);
    57         -}
           87  +})
           88  +
           89  +#undef _LL_fn
           90  +#undef _LL_impl
           91  +
           92  +#undef _ll_pushfn
           93  +#undef _ll_newfn
           94  +#undef _ll_dropfn
    58     95   
    59     96   #undef _ll_ffirst
    60     97   #undef _ll_flast
    61     98   #undef _ll_ns
    62     99   #undef _ll_box
    63    100   #undef _ll_obj
    64    101   #undef _ll_rec
    65    102   #undef _ll_iter
    66    103   #undef _ll_delete