Main Page | Modules | Data Structures | File List | Data Fields | Globals

sort.c File Reference


Detailed Description

Provides basic sorting routines.

Definition in file sort.c.

#include "../include/beeos.h"
#include "../include/bmalloc.h"
#include "../include/bstring.h"

Include dependency graph for sort.c:

Include dependency graph

Go to the source code of this file.

Functions

void bubblesort (char *base, ushort num, ushort size, sshort(*cmp_func)(const void *, const void *))


Function Documentation

void bubblesort char *  base,
ushort  num,
ushort  size,
sshort(*  cmp_func)(const void *, const void *)
 

Definition at line 36 of file sort.c.

References bfree(), bmalloc(), bmemcpy(), NULL, and ushort.

00038 {
00056     char *ptr;
00057     char *temp = bmalloc(size, NULL);
00058     ushort i, j;
00059     
00060     for (i = 0; i < num - 1; i++) {
00061         for (j = 0, ptr = base; j < num - 1 - i; j++, ptr += size) {
00062             if (0 > cmp_func(ptr, ptr + size)) {
00063                 bmemcpy(temp, ptr + size, size);
00064                 bmemcpy(ptr + size, ptr, size);
00065                 bmemcpy(ptr, temp, size);
00066             }
00067         }
00068     }
00069     bfree(temp);
00070     
00071     return;
00072 }

Here is the call graph for this function:


Generated on Sat Apr 10 17:08:23 2004 for BeeOS by doxygen 1.3.6-20040222