diff --git a/experiment/README.md b/experiment/README.md index 0f27c4e..73dfdaa 100644 --- a/experiment/README.md +++ b/experiment/README.md @@ -22,8 +22,8 @@ futiles. ## système de cache -new: Mon Jul 17 12:49:20 UTC 2023 +`new: Mon Jul 17 12:49:20 UTC 2023` En cours : définition d'à peu-près tout ce qu'il reste à faire pour avoir quelque chose qui fonctionne. -Plus d'information dans le [.h](cachegen.h). +Plus d'information dans le [.h](cachengn.h). diff --git a/experiment/cachengn.c b/experiment/cachengn.c index 3a1f67b..b7e4026 100644 --- a/experiment/cachengn.c +++ b/experiment/cachengn.c @@ -3,23 +3,143 @@ */ #include +#include +#include +#include +#include +#include "../floatimg.h" #include "cachengn.h" +extern int verbosity; + +static int nombre_slots = -1; +static int index_slot = -1; +static FimgCacheEntry *le_cache = NULL; + /* ------------------------------------------------------------ */ void cachengn_print_version(int k) { -printf("this is the version ZERO !!!\n"); +printf("\t!!! this is the version ZERO !!!\n"); +fprintf(stderr, "sizeof cache entry: %ld\n", sizeof(FimgCacheEntry)); + +if (k) fimg_print_version(0); } - /* ------------------------------------------------------------ */ -int init_empty_cache(int iw, int ih, int szc, int nbre) +/* + * + */ +int init_empty_cache(int iw, int ih, int szc, int wtfparam) { -return -1; +int idx; + +fprintf(stderr, ">>> %s ( %d %d %d %d )\n", __func__, + iw, ih, szc, wtfparam); + +/* MOLLYGUARD : don't init TWICE, please */ +if (NULL != le_cache) { + fprintf(stderr, "%s: there is a cache at %p\n", __func__, + le_cache); + return -2; + } + +/* allocate an prepare memory */ +if ( NULL==(le_cache=calloc(szc, sizeof(FimgCacheEntry))) ) { + fprintf(stderr, "%s: no memory, sorry...\n", __func__); + return -3; + } +fprintf(stderr, " slot array at %p\n", le_cache); +for (idx=0; idx>> %s ( '%s' %d )\n", __func__, fname, notused); + +/* please add molly guard ! */ + +if (notused) + fprintf(stderr, "in %s, notused was %d\n", __func__, notused); + +/* is the floatimg already in the cahce ? */ +for (idx=0; idx>> %s ( Ox%X )\n", __func__, flags); + +/* please add molly guard here */ + +fprintf(stderr, "cache at %p : %d slots, idx = %d\n", + le_cache, nombre_slots, index_slot); + +for (idx=0; idx +#include +#include "../floatimg.h" #include "cachengn.h" +int verbosity; + #define IMGW 320 #define IMGH 240 -#define SIZE 20 + +#define SIZE 5 // number of slots #define NBRI 1000 /* ------------------------------------------------------------ */ int main(int argc, char *argv[]) { int foo; +FloatImg *picz; +char *fname = "quux.fimg"; -fprintf(stderr, "Test of the cache engin - %s %s\n", __DATE__, __TIME__); +fprintf(stderr, "\nTest of the cache engin - %s %s\n", + __DATE__, __TIME__); cachengn_print_version(1); foo = init_empty_cache(IMGW, IMGH, SIZE, NBRI); -fprintf(stderr, "init_empty_cache --> %d\n", foo); +fprintf(stderr, " init_empty_cache --> %d\n", foo); + +foo = liste_le_cache((unsigned int)'U'); +fprintf(stderr, " liste le cache --> %d\n", foo); + +picz = give_me_thiz_picz(fname, 0); +if (NULL == picz) { + fprintf(stderr, " error 'givemeapicz' on '%s'\n", fname); + } + +picz = give_me_thiz_picz(fname, 0); +if (NULL == picz) { + fprintf(stderr, " error 'givemeapicz' on '%s'\n", fname); + } return 0; }