reverse(3)

reverse3

Reverse a list of chained elements

Synopsys

#include "mut.h"
chain_list ∗reverse(ptold)
chain_list ∗ptold;

Parameter

ptold

Pointer to a chain_list to be reversed

Overview

The reverse function allows to reverse the order of the elements of a chain_list. It means that the last element becomes the first one, the one before the last one the second one, and so on.

remark :

all mbk structures have for first field the NEXT field, so, with appropriate cast, one can reverse any mbk list. Let's notice that nothing in the C language description demands a structure to be defined in memory the same way its members are defined in C. But all compiler do it this way now a day. Let's hope it will continue!

Return value

reverse returns a pointer to the head of the reversed list.

Examples

#include "mut.h"
void reverse_con(p)
lofig_list ∗p;
{
	p->LOCON = (locon_list ∗)reverse((chain_list ∗)p->LOCON);
}

Releases

4 releases since Debian 7 (Wheezy); the text changed 1 time.

  1. 7–8
  2. 9–10

From alliance 5.1.1-3 in Debian 10 (Buster). Parsed by carta from the page's man source.