Posté le 20/10/2025 05:22
, i'm a bad at C
Planète Casio v4.3 © créé par Neuronix et Muelsaco 2004 - 2025 | Il y a 88 connectés | Nous contacter | Qui sommes-nous ? | Licences et remerciements
Planète Casio est un site communautaire non affilié à Casio. Toute reproduction de Planète Casio, même partielle, est interdite.
Les programmes et autres publications présentes sur Planète Casio restent la propriété de leurs auteurs et peuvent être soumis à des licences ou copyrights.
CASIO est une marque déposée par CASIO Computer Co., Ltd
Citer : Posté le 20/10/2025 10:04 | #
I do not have time to debug this, but the List_Push function looks unsafe and broken.
If the write fails, you still have updated the number of elements in your list.
Moreover you copy elements at position list->count * list->size but you want them to be at (list_count - 1) * list_size (when list_count = 1 you want to write at index 0).
What would be better is something like this:
// If there are no elements in the list, allocate a new one
if (list->count == 0) {
list->items = malloc(list->size);
if (list->items == NULL) return 1;
}
// If there are already some elements, reallocate the existing one
else {
list->items = realloc(list->items, (list->count + 1) * list->size);
if (list->items == NULL) return 1;
}
// If the execution reach this, it means that allocation succeded
memcpy((char*)((char*)(list->items) + (list->count * list->size)) - list->size, item, list->size);
list->count++;
return 0;
}
I did not compile it but it looks ok. You don't need those goto/labels BTW
Citer : Posté le 20/10/2025 10:17 | #
I use the list.c code just to make it easier for myself. I'm primarily a Python programmer and feel unfamiliar with C.
The list code works, and I've built a FxLinux add-in with it, and everything works. I think the problem is with the main.c file.
Citer : Posté le 20/10/2025 11:04 | # |
Fichier joint
From warnings:
List_Init(ve_list, SCREEN);
You didn't allocate storage for a list_t, so you're writing to random things in the initialization code. It should be something like:
List_Init(ve_list, SCREEN);
In general you could also allocate the list on the stack (list_t l; List_Init(&l);) but it's not applicable here because you want to return the list and you can't return the address of a local variable.
Other than this the code is quite complicated. There are way too many copies, conversions, etc. everywhere. Try to think about what data you're using and why you need to copy it all the time. The file access code was super complicated due to a mix of BFile and not BFile (not particularly your fault). Ultimately the cause of the problem was that your opendir() didn't filter for .ve files so you were opening the wrong thing.
Attached is an archive with a working build (I get a cube from the example, at least) with all the BFile code removed and the rest hopefully quite simplified. Notice how the only copies in the entire file management code are for copying the list of entries and concatenating the folder and file paths.
Citer : Posté le 20/10/2025 11:19 | #
I modified the list definition.
The program still gives me a blank white screen. Did it work for you? Can you share it?
Sorry for the inconvenience.
Citer : Posté le 20/10/2025 11:56 | #
Please check the archive attached to my previous message (on the top right, "Fichier joint"), which contains the code I modified
Citer : Posté le 20/10/2025 12:57 | #
Please check the archive attached to my previous message (on the top right, "Fichier joint"), which contains the code I modified
oh found it thanks.
model didn't work, but files is fine, i will do some debugging
Citer : Posté le 20/10/2025 13:04 | #
Now its Wooooooooooooooooooooooooooooooooooooorks