1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-06-03 09:08:32 +03:00
wernermisc/qpkg/fixup.c
Werner Almesberger bbf9c42bc8 qpkg: move "struct pkg" and its allocation from gobble.c and qpkg.h to pkg.[hc]
- Makefile (OBJS_qpkg): added pkg.o
- gobble.c (gobble_buf): moved "struct pkg" allocation to function new_pkg
  in pkg.c
- qpkg.h: moved "struct pkg" and subordinate structures to pkg.h
- pkg.h, pkg.c (new_pkg, free_pkg): provide package structure definition,
  allocation, and deallocation
- fixup.c, gobble.c, prereq.c, qpkg.c: include "pkg.h"
- gobble.c (finish_pkg): use free_pkg instead of just "free" to avoid
  leaking memory
2010-11-22 16:19:32 -03:00

45 lines
978 B
C

/*
* fixup.c - Adjust things after parsing is done
*
* Written 2010 by Werner Almesberger
* Copyright 2010 Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include <stdio.h>
#include "jrb.h"
#include "pkg.h"
#include "qpkg.h"
#include "fixup.h"
void sort_versions(void)
{
const struct jrb *n;
struct pkg **a, **b;
struct pkg *tmp;
for (n = jrb_first(packages->root); n != jrb_nil(packages->root);
n = jrb_next(n))
for (a = (struct pkg **) &n->val; *a; a = &(*a)->more)
for (b = &(*a)->more; *b;)
if (comp_versions((*a)->version,
(*b)->version) >= 0)
b = &(*b)->more;
else {
tmp = *a;
*a = *b;
*b = tmp;
tmp = (*a)->more;
(*a)->more = (*b)->more;
(*b)->more = tmp;
}
}