X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Ftest-framework%2Fyaffs_osglue.c;h=2cc18bbdcb6bdec25eafef419df5caac894ed42a;hp=e31ad222a99572c4a6c0ec5204dc0ff51decdce9;hb=f83f5b03c1eea3fe26a0929583ffbd16df7c64f0;hpb=de117c122a4328102305eb6dbe57ad22c1b1eba8 diff --git a/direct/test-framework/yaffs_osglue.c b/direct/test-framework/yaffs_osglue.c index e31ad22..2cc18bb 100644 --- a/direct/test-framework/yaffs_osglue.c +++ b/direct/test-framework/yaffs_osglue.c @@ -1,8 +1,7 @@ /* * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. * - * Copyright (C) 2002-2011 Aleph One Ltd. - * for Toby Churchill Ltd and Brightstar Engineering + * Copyright (C) 2002-2018 Aleph One Ltd. * * Created by Charles Manning * @@ -53,6 +52,9 @@ int yaffsfs_GetLastError(void) */ int yaffsfs_CheckMemRegion(const void *addr, size_t size, int write_request) { + (void) size; + (void) write_request; + if(!addr) return -1; return 0; @@ -91,6 +93,8 @@ static void *bg_gc_func(void *dummy) int result; int next_urgent; + (void)dummy; + /* Sleep for a bit to allow start up */ sleep(2); @@ -161,6 +165,48 @@ u32 yaffsfs_CurrentTime(void) * Functions to allocate and free memory. */ + +static unsigned malloc_high_water; +static unsigned malloc_currently_allocated; + +#ifdef CONFIG_YAFFS_MONITOR_MALLOC + +#include +static void yaffsfs_malloc_add(void *ptr) +{ + unsigned this_size = malloc_usable_size(ptr); + malloc_currently_allocated += this_size; + + if (malloc_currently_allocated > malloc_high_water) + malloc_high_water = malloc_currently_allocated; +} + +static void yaffsfs_malloc_remove(void *ptr) +{ + unsigned this_size = malloc_usable_size(ptr); + malloc_currently_allocated -= this_size; +} +#else +static void yaffsfs_malloc_add(void *ptr) +{ + (void)ptr; +} + +static void yaffsfs_malloc_remove(void *ptr) +{ + (void)ptr; +} +#endif + +void yaffsfs_get_malloc_values(unsigned *current, unsigned *high_water) +{ + if (current) + *current = malloc_currently_allocated; + if(high_water) + *high_water = malloc_high_water; +} + + #ifdef CONFIG_YAFFS_TEST_MALLOC static int yaffs_kill_alloc = 0; @@ -178,6 +224,7 @@ void *yaffsfs_malloc(size_t size) this = malloc(size); if(this) total_malloced += size; + yaffsfs_malloc_add(this); return this; } @@ -185,13 +232,19 @@ void *yaffsfs_malloc(size_t size) void *yaffsfs_malloc(size_t size) { - return malloc(size); + void *this = malloc(size); + yaffsfs_malloc_add(this); + return this; } #endif + + + void yaffsfs_free(void *ptr) { + yaffsfs_malloc_remove(ptr); free(ptr); }