From: John Beppu Date: Wed, 22 Dec 1999 17:57:31 +0000 (-0000) Subject: added hooks for sort X-Git-Tag: 0_40~32 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=019513a59ffd966cca51d6616757295a46869e4a;p=oweals%2Fbusybox.git added hooks for sort --- diff --git a/applets/busybox.c b/applets/busybox.c index 895accd93..cd4ab8fcd 100644 --- a/applets/busybox.c +++ b/applets/busybox.c @@ -184,6 +184,9 @@ static const struct Applet applets[] = { #ifdef BB_SLEEP //bin {"sleep", sleep_main}, #endif +#ifdef BB_SORT //bin + {"sort", sort_main}, +#endif #ifdef BB_SYNC //bin {"sync", sync_main}, #endif diff --git a/busybox.c b/busybox.c index 895accd93..cd4ab8fcd 100644 --- a/busybox.c +++ b/busybox.c @@ -184,6 +184,9 @@ static const struct Applet applets[] = { #ifdef BB_SLEEP //bin {"sleep", sleep_main}, #endif +#ifdef BB_SORT //bin + {"sort", sort_main}, +#endif #ifdef BB_SYNC //bin {"sync", sync_main}, #endif diff --git a/busybox.def.h b/busybox.def.h index 3a64c1a54..3c290f7a4 100644 --- a/busybox.def.h +++ b/busybox.def.h @@ -64,6 +64,7 @@ //#define BB_SFDISK #define BB_SED #define BB_SLEEP +#define BB_SORT #define BB_SWAPONOFF #define BB_SYNC #define BB_SYSLOGD diff --git a/coreutils/sort.c b/coreutils/sort.c index d82351797..f3f9fca1d 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c @@ -90,6 +90,17 @@ line_newFromFile(FILE *src) return NULL; } +/* Line destructor */ +static Line * +line_release(Line *self) +{ + if (self->data) { + free(self->data); + free(self); + } + return self; +} + /* Comparison */ @@ -148,7 +159,16 @@ list_writeToFile(List *self, FILE* dst) static List * list_release(List *self) { - return self; + Line *i; + Line *die; + + i = self->head; + while (i) { + die = i; + i = die->next; + line_delete(die); + } + return self; /* bad poetry? */ } @@ -195,4 +215,4 @@ sort_main(int argc, char **argv) exit(0); } -/* $Id: sort.c,v 1.2 1999/12/22 00:30:29 beppu Exp $ */ +/* $Id: sort.c,v 1.3 1999/12/22 17:57:31 beppu Exp $ */ diff --git a/internal.h b/internal.h index 6bb9341ef..05e3904e6 100644 --- a/internal.h +++ b/internal.h @@ -113,6 +113,7 @@ extern int sh_main(int argc, char** argv); extern int sfdisk_main(int argc, char** argv); extern int sed_main(int argc, char** argv); extern int sleep_main(int argc, char** argv); +extern int sort_main(int argc, char** argv); extern int swap_on_off_main(int argc, char** argv); extern int sync_main(int argc, char** argv); extern int syslogd_main(int argc, char **argv); diff --git a/sort.c b/sort.c index d82351797..f3f9fca1d 100644 --- a/sort.c +++ b/sort.c @@ -90,6 +90,17 @@ line_newFromFile(FILE *src) return NULL; } +/* Line destructor */ +static Line * +line_release(Line *self) +{ + if (self->data) { + free(self->data); + free(self); + } + return self; +} + /* Comparison */ @@ -148,7 +159,16 @@ list_writeToFile(List *self, FILE* dst) static List * list_release(List *self) { - return self; + Line *i; + Line *die; + + i = self->head; + while (i) { + die = i; + i = die->next; + line_delete(die); + } + return self; /* bad poetry? */ } @@ -195,4 +215,4 @@ sort_main(int argc, char **argv) exit(0); } -/* $Id: sort.c,v 1.2 1999/12/22 00:30:29 beppu Exp $ */ +/* $Id: sort.c,v 1.3 1999/12/22 17:57:31 beppu Exp $ */