Loading...
Searching...
No Matches
omList.c File Reference
`#include "omConfig.h"`
`#include "omalloc.h"`
`#include "omDebug.h"`

Go to the source code of this file.

## Macros

#define | NULL ((void*) 0)
#define | _VALUE(list, offset)
#define | VALUE(list, offset)
#define | NEXT(list)
#define | ITER(list)

## Functions

int | _omListLength (void *list, int next)
void * | _omListLast (void *list, int next)
void * | _omListHasCycle (void *list, int next)
void * | _omIsOnList (void *list, int next, void *addr)
void * | _omRemoveFromList (void *list, int next, void *addr)
void * | _omFindInList (void *list, int next, int long_field, unsigned long what)
void * | _omFindInSortedList (void *list, int next, int long_field, unsigned long what)
void * | _omRemoveFromSortedList (void *list, int next, int long_field, void *addr)
void * | _omInsertInSortedList (void *list, int next, int long_field, void *addr)
omError_t | _omCheckList (void *list, int next, int level, omError_t report, OM_FLR_DECL)
omError_t | _omCheckSortedList (void *list, int next, int long_field, int level, omError_t report, OM_FLR_DECL)

## Macro Definition Documentation

## _VALUE

#define _VALUE | ( |  | list,
|  |  | offset )

Value:
*((void**) ((char *)list + offset))
offset
STATIC_VAR int offset
Definition janet.cc:29

Definition at line 15 of file omList.c.

## ITER

#define ITER | ( |  | list | ) |

Value:
list = NEXT(list)
NEXT
#define NEXT(list)
Definition omList.c:17

Definition at line 18 of file omList.c.

## NEXT

#define NEXT | ( |  | list | ) |

Value:
_VALUE(list, next)
next
ListNode * next
Definition janet.h:31
_VALUE
#define _VALUE(list, offset)
Definition omList.c:15

Definition at line 17 of file omList.c.

## NULL

#define NULL ((void*) 0)

Definition at line 12 of file omList.c.

## VALUE

#define VALUE | ( |  | list,
|  |  | offset )

Value:
(unsigned long) _VALUE(list, offset)

Definition at line 16 of file omList.c.

## Function Documentation

## _omCheckList()

omError_t _omCheckList | ( | void * | list,
|  | int | next,
|  | int | level,
|  | omError_t | report,
|  | OM_FLR_DECL | )

Definition at line 178 of file omList.c.

{
if (level < 1) return omError_NoError;
if (level == 1)
{
while (list != NULL)
{
omCheckReturn(omCheckPtr(list, report, OM_FLR_VAL));
ITER(list);
}
}
else
{
void* l1 = list;
void* l2;
int l = 0, i;
l1 = list;
while (l1 != NULL)
{
omCheckReturn(omCheckPtr(l1, report, OM_FLR_VAL));
i = 0;
l2 = list;
while (l1 != l2)
{
i++;
ITER(l2);
}
if (i != l)
return omReportError(omError_ListCycleError, report, OM_FLR_VAL, "");
ITER(l1);
l++;
}
}
return omError_NoError;
}
level
int level(const CanonicalForm &f)
Definition canonicalform.h:331
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
omCheckPtr
omError_t omCheckPtr(const void *ptr, omError_t report, OM_FLR_DECL)
Definition omDebugCheck.c:136
omCheckReturn
#define omCheckReturn(cond)
Definition omDebug.h:170
omReportError
omError_t omReportError(omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
Definition omError.c:80
omError_ListCycleError
@ omError_ListCycleError
Definition omError.h:34
omError_NoError
@ omError_NoError
Definition omError.h:18
NULL
#define NULL
Definition omList.c:12
ITER
#define ITER(list)
Definition omList.c:18

## _omCheckSortedList()

omError_t _omCheckSortedList | ( | void * | list,
|  | int | next,
|  | int | long_field,
|  | int | level,
|  | omError_t | report,
|  | OM_FLR_DECL | )

Definition at line 216 of file omList.c.

{
void* prev = NULL;
if (level <= 1) return omError_NoError;
if (level == 1)
{
while (list != NULL)
{
omCheckReturn(omCheckPtr(list, report, OM_FLR_VAL));
if (prev != NULL && VALUE(prev, long_field) > VALUE(list, long_field))
return omReportError(omError_SortedListError, report, OM_FLR_VAL,
"%d > %d", VALUE(prev, long_field), VALUE(list, long_field));
prev = list;
ITER(list);
}
}
else
{
void* l1 = list;
void* l2;
int l = 0, i;
while (l1 != NULL)
{
omCheckReturn(omCheckPtr(l1, report, OM_FLR_VAL));
if (prev != NULL && VALUE(prev, long_field) > VALUE(l1, long_field))
return omReportError(omError_SortedListError, report, OM_FLR_VAL,
"%d > %d", VALUE(prev, long_field), VALUE(l1, long_field));
i = 0;
l2 = list;
while (l1 != l2)
{
i++;
ITER(l2);
}
omCheckReturnError(i != l, omError_ListCycleError);
prev = l1;
ITER(l1);
l++;
}
}
return omError_NoError;
}
omCheckReturnError
#define omCheckReturnError(cond, error)
Definition omDebug.h:172
omError_SortedListError
@ omError_SortedListError
Definition omError.h:35
VALUE
#define VALUE(list, offset)
Definition omList.c:16

## _omFindInList()

void * _omFindInList | ( | void * | list,
|  | int | next,
|  | int | long_field,
|  | unsigned long | what )

Definition at line 100 of file omList.c.

{
while (list != NULL)
{
if (VALUE(list, long_field) == what) return list;
ITER(list);
}
return NULL;
}

## _omFindInSortedList()

void * _omFindInSortedList | ( | void * | list,
|  | int | next,
|  | int | long_field,
|  | unsigned long | what )

Definition at line 110 of file omList.c.

{
while (list != NULL)
{
if (VALUE(list, long_field) >= what)
{
if (VALUE(list, long_field) == what) return list;
return NULL;
}
ITER(list);
}
return NULL;
}

## _omInsertInSortedList()

void * _omInsertInSortedList | ( | void * | list,
|  | int | next,
|  | int | long_field,
|  | void * | addr )

Definition at line 148 of file omList.c.

{
unsigned long what = VALUE(addr, long_field);
if (list == NULL || what <= VALUE(list, long_field))
{
NEXT(addr) = list;
return addr;
}
else
{
void* prev = list;
void* curr = NEXT(list);
while (curr != NULL && VALUE(curr, long_field) < what)
{
prev = curr;
ITER(curr);
}
NEXT(prev) = addr;
NEXT(addr) = curr;
return list;
}
}

## _omIsOnList()

void * _omIsOnList | ( | void * | list,
|  | int | next,
|  | void * | addr )

Definition at line 66 of file omList.c.

{
if (addr == NULL)
return (NULL);
while (list != NULL)
{
if (addr == list) return addr;
ITER(list);
}
return 0;
}

## _omListHasCycle()

void * _omListHasCycle | ( | void * | list,
|  | int | next )

Definition at line 42 of file omList.c.

{
void* l1 = list;
void* l2;
int l = 0, i;
while (l1 != NULL)
{
i = 0;
l2 = list;
while (l1 != l2)
{
i++;
ITER(l2);
}
if (i != l) return l1;
ITER(l1);
l++;
}
return NULL;
}

## _omListLast()

void * _omListLast | ( | void * | list,
|  | int | next )

Definition at line 32 of file omList.c.

{
if (list == NULL) return NULL;
while (NEXT(list) != NULL) ITER(list);
return list;
}

## _omListLength()

int _omListLength | ( | void * | list,
|  | int | next )

Definition at line 20 of file omList.c.

{
int l = 0;
while (list != NULL)
{
l++;
ITER(list);
}
return l;
}

## _omRemoveFromList()

void * _omRemoveFromList | ( | void * | list,
|  | int | next,
|  | void * | addr )

Definition at line 79 of file omList.c.

{
void* nlist;
void* olist;
if (list == NULL) return NULL;
nlist = NEXT(list);
if (list == addr) return nlist;
olist = list;
while (nlist != NULL && nlist != addr)
{
list = nlist;
ITER(nlist);
}
if (nlist != NULL) NEXT(list) = NEXT(nlist);
return olist;
}

## _omRemoveFromSortedList()

void * _omRemoveFromSortedList | ( | void * | list,
|  | int | next,
|  | int | long_field,
|  | void * | addr )

Definition at line 125 of file omList.c.

{
void* nlist;
void* olist;
unsigned long what = VALUE(addr, long_field);
if (list == NULL) return NULL;
nlist = NEXT(list);
if (list == addr) return nlist;
if (VALUE(list, long_field) > what) return list;
olist = list;
while (nlist != NULL && nlist != addr)
{
if (VALUE(list, long_field) > what) return olist;
list = nlist;
ITER(nlist);
}
if (nlist != NULL) NEXT(list) = NEXT(nlist);
return olist;
}