Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 348 → Rev 349

/SPARTAN/trunk/src/lib/sort.c
31,6 → 31,8
#include <sort.h>
#include <panic.h>
 
#define EBUFSIZE 32
 
static void _qsort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b), void * pivot, void * tmp);
 
/*
37,24 → 39,42
* Wrapper method for quicksort algorithm to decrease amount of allocations
*/
void qsort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b)) {
void * tmp = (void *) malloc(e_size);
void * pivot = (void *) malloc(e_size);
__u8 buf_tmp[EBUFSIZE];
__u8 buf_pivot[EBUFSIZE];
void * tmp = buf_tmp;
void * pivot = buf_pivot;
 
if (e_size > EBUFSIZE) {
pivot = (void *) malloc(e_size);
tmp = (void *) malloc(e_size);
if (!tmp || !pivot) {
panic("Cannot allocate memory\n");
if (!tmp || !pivot) {
panic("Cannot allocate memory\n");
}
}
 
_qsort(data, n, e_size, cmp, pivot, tmp);
free(tmp);
free(pivot);
if (e_size > EBUFSIZE) {
free(tmp);
free(pivot);
}
}
 
 
void bubblesort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b)) {
__u8 buf_slot[EBUFSIZE];
bool done = false;
void * p;
void * slot = (void *) malloc(e_size);
void * slot = buf_slot;
if (e_size > EBUFSIZE) {
slot = (void *) malloc(e_size);
if (!slot) {
panic("Cannot allocate memory\n");
}
}
 
while (!done) {
done = true;
68,7 → 88,9
}
}
free(slot);
if (e_size > EBUFSIZE) {
free(slot);
}
}
 
static void _qsort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b), void * pivot, void * tmp) {
/SPARTAN/trunk/arch/amd64/include/mm/frame.h
1,5 → 1,5
/*
* Copyright (C) 2005 Martin Decky
* Copyright (C) 2005 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/SPARTAN/trunk/arch/amd64/include/mm/page.h
1,5 → 1,5
/*
* Copyright (C) 2005 Martin Decky
* Copyright (C) 2005 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/SPARTAN/trunk/arch/amd64/include/mm/vm.h
1,5 → 1,5
/*
* Copyright (C) 2005 Martin Decky
* Copyright (C) 2005 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/SPARTAN/trunk/arch/ia32/src/acpi/madt.c
112,16 → 112,14
 
int madt_cmp(void * a, void * b)
{
return
(((struct madt_apic_header *) a)->type > ((struct madt_apic_header *) b)->type) ?
1 :
((((struct madt_apic_header *) a)->type < ((struct madt_apic_header *) b)->type) ? -1 : 0);
return
(((struct madt_apic_header *) a)->type > ((struct madt_apic_header *) b)->type) ?
1 :
((((struct madt_apic_header *) a)->type < ((struct madt_apic_header *) b)->type) ? -1 : 0);
}
void acpi_madt_parse(void)
{
 
 
struct madt_apic_header *end = (struct madt_apic_header *) (((__u8 *) acpi_madt) + acpi_madt->header.length);
struct madt_apic_header *h;