website logo
Auteur
avatar
rusback

Forum » » Développement » » Layers


Post� : 01-11-2010 14:18 icone du post

Hello,

J'ai un petit souci concernant une partie d'un programme sur les layers...
Ca bugue grave avec une libération de mémoire incompléte avec un pointeur invalide...

Voici 2 structures pour commencer, qui concerne le programme.

struct EntryInfo
{
struct FullLayer *ei_Layer;
struct EntryInfo *ei_Next;
struct EntryInfo *ei_Pred;
struct Icons ei_Image;
struct Module *ei_module;
struct TaskList *ei_tl;
CxObj *ei_cxobj;
BOOL ei_redraw;
BOOL ei_!refresh!;
BOOL ei_owncolor;
BOOL ei_changed;
BOOL ei_valid;
....
....
....
}

struct FullLayer
{
struct Node fl_node;
struct EntryInfo *fl_Entry;
struct EntryInfo *fl_Active;
struct EntryInfo *fl_LastActive;
struct EntryInfo *fl_Remove;
struct EntryInfo *fl_Current;
struct EntryInfo *fl_Parent;
struct Window *fl_Window;
....
....
....
}

Voici la partie du programme qui plante...

struct FullLayer *ReadDirectory(BPTR Prefs)
{
struct EntryInfo *ei, *lei;
struct FullLayer *Layer;
char *Line;
LONG Back;
BOOL Test;
BOOL upSet;
ULONG dummy, rgb, txtrgb;

upSet=FALSE;
cnt++;
rgb = 0x00;
txtrgb = textrgb;
Layer = AllocPooled(pool, sizeof(struct FullLayer));
if(Layer)
{
Layer->fl_rgb = rgb;
Layer->fl_textrgb = txtrgb;
Layer->fl_Entry = AllocPooled(pool, sizeof(struct EntryInfo));
if(Layer->fl_Entry)
{
Layer->fl_Entry->ei_rgb = Layer->fl_rgb; //trgb;
Layer->fl_Entry->ei_textrgb = Layer->fl_textrgb;
Layer->fl_Entry->ei_labelrgb = Layer->fl_textrgb;
Test = TRUE;
Layer->fl_Active = Layer->fl_Entry;;
ei = Layer->fl_Entry;
ei->ei_Ratio = 100;
ei->ei_stack = 4096;
lei = NULL;
}
else
{
FreePooled(pool, (UBYTE*)Layer, sizeof(struct FullLayer));
Layer = NULL;
}
}
return(Layer);
}

J'ai fait plusieurs essais...
mon premier essai a été de mettre entre /*... */ la partie commençant entre
Layer->fl_rgb = rgb; et finissant à la fin de Layer = NULL; } résultat ca buggue pas ca roule...
Mon essai suivant a été de tout laisser et là ça buggue dur lors de l'éxécution du programme.
Pourtant, tout me parait normal.

Si quelqu'un pouvait me donner un coup de main ou me donner un indice ou + pour m'aider je serais bien content
pour continuer ce programme.
MorphOS, c'est le meilleur

Cet article provient de Meta-MorphOS
https://www.meta-morphos.org/viewtopic.php?topic=661&forum=52