summaryrefslogtreecommitdiffstats
path: root/toolbox
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2016-01-22 18:32:57 +0100
committerEthan Yonker <dees_troy@teamw.in>2016-01-22 18:34:10 +0100
commit916cae8fa3a451c4fc802814cc9f118ad4fb9512 (patch)
treea47e14ae3b2e7fa263879a1d44663b72a462e871 /toolbox
parentAdd zip and unzip when using toybox (diff)
downloadandroid_bootable_recovery-916cae8fa3a451c4fc802814cc9f118ad4fb9512.tar
android_bootable_recovery-916cae8fa3a451c4fc802814cc9f118ad4fb9512.tar.gz
android_bootable_recovery-916cae8fa3a451c4fc802814cc9f118ad4fb9512.tar.bz2
android_bootable_recovery-916cae8fa3a451c4fc802814cc9f118ad4fb9512.tar.lz
android_bootable_recovery-916cae8fa3a451c4fc802814cc9f118ad4fb9512.tar.xz
android_bootable_recovery-916cae8fa3a451c4fc802814cc9f118ad4fb9512.tar.zst
android_bootable_recovery-916cae8fa3a451c4fc802814cc9f118ad4fb9512.zip
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/Android.mk4
-rw-r--r--toolbox/dynarray.c104
-rw-r--r--toolbox/dynarray.h4
3 files changed, 6 insertions, 106 deletions
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index 4698cd250..dc4252da7 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -220,10 +220,12 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
# which takes up more space than is necessary so long as we are still
# including busybox.
LOCAL_SRC_FILES += \
- ../../../$(TWRP_TOOLBOX_PATH)/dynarray.c \
../../../$(TWRP_TOOLBOX_PATH)/getprop.c \
../../../$(TWRP_TOOLBOX_PATH)/setprop.c
OUR_TOOLS += getprop setprop
+ ifneq ($(TW_USE_TOOLBOX), true)
+ LOCAL_SRC_FILES += ls.c
+ endif
endif
LOCAL_MODULE := toolbox_recovery
diff --git a/toolbox/dynarray.c b/toolbox/dynarray.c
deleted file mode 100644
index 3c35aa950..000000000
--- a/toolbox/dynarray.c
+++ /dev/null
@@ -1,104 +0,0 @@
-#include "dynarray.h"
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-
-void
-dynarray_init( dynarray_t *a )
-{
- a->count = a->capacity = 0;
- a->items = NULL;
-}
-
-
-static void
-dynarray_reserve_more( dynarray_t *a, int count )
-{
- int old_cap = a->capacity;
- int new_cap = old_cap;
- const int max_cap = INT_MAX/sizeof(void*);
- void** new_items;
- int new_count = a->count + count;
-
- if (count <= 0)
- return;
-
- if (count > max_cap - a->count)
- abort();
-
- new_count = a->count + count;
-
- while (new_cap < new_count) {
- old_cap = new_cap;
- new_cap += (new_cap >> 2) + 4;
- if (new_cap < old_cap || new_cap > max_cap) {
- new_cap = max_cap;
- }
- }
- new_items = realloc(a->items, new_cap*sizeof(void*));
- if (new_items == NULL)
- abort();
-
- a->items = new_items;
- a->capacity = new_cap;
-}
-
-void
-dynarray_append( dynarray_t *a, void* item )
-{
- if (a->count >= a->capacity)
- dynarray_reserve_more(a, 1);
-
- a->items[a->count++] = item;
-}
-
-void
-dynarray_done( dynarray_t *a )
-{
- free(a->items);
- a->items = NULL;
- a->count = a->capacity = 0;
-}
-
-// string arrays
-
-void strlist_init( strlist_t *list )
-{
- dynarray_init(list);
-}
-
-void strlist_append_b( strlist_t *list, const void* str, size_t slen )
-{
- char *copy = malloc(slen+1);
- memcpy(copy, str, slen);
- copy[slen] = '\0';
- dynarray_append(list, copy);
-}
-
-void strlist_append_dup( strlist_t *list, const char *str)
-{
- strlist_append_b(list, str, strlen(str));
-}
-
-void strlist_done( strlist_t *list )
-{
- STRLIST_FOREACH(list, string, free(string));
- dynarray_done(list);
-}
-
-static int strlist_compare_strings(const void* a, const void* b)
-{
- const char *sa = *(const char **)a;
- const char *sb = *(const char **)b;
- return strcmp(sa, sb);
-}
-
-void strlist_sort( strlist_t *list )
-{
- if (list->count > 0) {
- qsort(list->items,
- (size_t)list->count,
- sizeof(void*),
- strlist_compare_strings);
- }
-}
diff --git a/toolbox/dynarray.h b/toolbox/dynarray.h
index f73fb3b9c..0ca54fdf6 100644
--- a/toolbox/dynarray.h
+++ b/toolbox/dynarray.h
@@ -1,6 +1,8 @@
#ifndef DYNARRAY_H
#define DYNARRAY_H
+// These functions are now found in system/core/toolbox/ls.c
+
#include <stddef.h>
/* simple dynamic array of pointers */
@@ -77,4 +79,4 @@ void strlist_append_dup( strlist_t *list, const char *str);
/* sort the strings in a given list (using strcmp) */
void strlist_sort( strlist_t *list );
-#endif /* DYNARRAY_H */ \ No newline at end of file
+#endif /* DYNARRAY_H */