Skip to content

Commit f20b23e

Browse files
committed
Use malloc, not GEMDOS Malloc for cf_malloc(FALSE)
See #5
1 parent cc60c94 commit f20b23e

File tree

8 files changed

+79
-30
lines changed

8 files changed

+79
-30
lines changed

backgrd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static void cf_background(GRECT *box, MFDB *buffer, _WORD get)
7272
xy[6] = r.g_x + r.g_w - 1;
7373
xy[7] = r.g_y + r.g_h - 1;
7474
vro_cpyfm(cf_vdi_handle, S_ONLY, xy, buffer, &screen);
75-
Mfree(buffer->fd_addr);
75+
free(buffer->fd_addr);
7676
}
7777
show_mouse();
7878
}

cfmalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void *cf_malloc(long size, char *who, int global)
3434
if (global && getcookie("MiNT", NULL))
3535
r = (void *)Mxalloc(size, 0x23);
3636
else
37-
r = (void *)Malloc(size);
37+
r = (void *)malloc(size);
3838

3939
if (r == NULL)
4040
{

cicon.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,16 @@ CICON *fix_cicon(CICONBLK *cicnblk, _WORD screen_planes, _WORD handle)
211211

212212
if (best_icn != NULL) /* passendes Farbicon gefunden */
213213
{
214-
new_icn = (CICON*)cf_malloc(sizeof(CICON), "fix_cicon", FALSE);
214+
new_icn = (CICON*)cf_malloc(sizeof(CICON), "fix_cicon", FALSE); /* leaked */
215215
*new_icn = *best_icn;
216216

217217
if (best_planes > 1)
218218
new_icn->num_planes = screen_planes;
219219
else
220220
new_icn->num_planes = 1;
221221

222-
new_icn->col_data = cf_malloc(len * screen_planes, "fix_cicon", FALSE);
223-
new_icn->sel_data = cf_malloc(len * screen_planes, "fix_cicon", FALSE);
222+
new_icn->col_data = cf_malloc(len * screen_planes, "fix_cicon", FALSE); /* leaked */
223+
new_icn->sel_data = cf_malloc(len * screen_planes, "fix_cicon", FALSE); /* leaked */
224224

225225
if (best_planes > 1)
226226
{
@@ -259,8 +259,8 @@ CICON *fix_cicon(CICONBLK *cicnblk, _WORD screen_planes, _WORD handle)
259259
d.fd_addr = new_icn->sel_data;
260260
vr_trnfm(handle, &s, &d);
261261

262-
Mfree(buf2);
263-
Mfree(buf1);
262+
free(buf2);
263+
free(buf1);
264264
}
265265
else
266266
{

filesel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ int select_file(char *path, char *name, char *mask, char *title, FSEL_CB open_cb
276276
}
277277
for (i = 0; i < SLCT_ANZ; i++)
278278
if (files[i] != NULL)
279-
Mfree(files[i]);
279+
free(files[i]);
280280

281281
/* leeren */
282282
path[0] = '\0';

mdclose.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ void close_mdial(MDIAL *dial)
7070
dial->tree[0].ob_y += dial->delta_y;
7171

7272
__mdial_md_list = dial->next;
73-
Mfree(dial);
73+
free(dial);
7474
}
7575
}

ppfree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ _WORD free_popup(POPUP *p)
4141
free((char *)get_obspec(p->tree, i)); /* free_string freigeben */
4242
} while (!(p->tree[i].ob_flags & OF_LASTOB));
4343

44-
Mfree(p->tree);
44+
free(p->tree);
4545

4646
return TRUE;
4747
}

userdef.c

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -459,31 +459,75 @@ static void init_inline_rsc(void)
459459
check_cib->mainlist = fix_cicon(check_cib, i, handle);
460460
}
461461

462-
static void make_userdef(OBJECT *tree, _WORD obj, _WORD __CDECL (*proc)(PARMBLK *p))
462+
static void make_userdef(USERBLK *uPtr, OBJECT *tree, _WORD obj, _WORD __CDECL (*proc)(PARMBLK *p))
463463
{
464-
USERBLK *uPtr;
465-
466-
uPtr = (USERBLK *)cf_malloc(sizeof(USERBLK), "make_userdef", FALSE);
467-
if (uPtr != NULL)
468-
{
469-
uPtr->ub_code = proc; /* neue Zeichenfunktion */
470-
uPtr->ub_parm = tree[obj].ob_spec.index; /* alte obSpec sichern */
464+
uPtr->ub_code = proc; /* neue Zeichenfunktion */
465+
uPtr->ub_parm = tree[obj].ob_spec.index; /* alte obSpec sichern */
471466

472-
/* alten Typ hochschieben und neuen eintragen */
473-
tree[obj].ob_type = (tree[obj].ob_type << 8) | G_USERDEF;
474-
tree[obj].ob_spec.userblk = uPtr; /* Userblock eintragen */
475-
}
467+
/* alten Typ hochschieben und neuen eintragen */
468+
tree[obj].ob_type = (tree[obj].ob_type << 8) | G_USERDEF;
469+
tree[obj].ob_spec.userblk = uPtr; /* Userblock eintragen */
476470
}
477471

478472
/* -- exportierte Funtkionen ------------------------------------------------- */
479473

480474
void fix_dial(OBJECT *tree)
481475
{
482476
_WORD mtyp, obj;
477+
USERBLK *uPtr;
478+
_WORD count;
483479

484480
if (!tree)
485481
return;
486482

483+
/* first pass: count number of USERBLKs needed */
484+
obj = -1;
485+
count = 0;
486+
do
487+
{
488+
obj++;
489+
mtyp = get_magx_obj(tree, obj);
490+
491+
/* Ein paar Erweiterungen, die MagiC auch nicht kann */
492+
switch (mtyp)
493+
{
494+
case MX_GROUPBOX2:
495+
count++;
496+
break;
497+
}
498+
499+
/* den Rest nur, wenn keine WHITEBACK-Buttons verfgbar sind */
500+
if (!mx_buttons || use_all_userdefs)
501+
{
502+
switch (mtyp)
503+
{
504+
case MX_UNDERLINE:
505+
count++;
506+
break;
507+
case MX_GROUPBOX:
508+
count++;
509+
break;
510+
case MX_RADIO:
511+
case MX_SCRADIO:
512+
count++;
513+
break;
514+
case MX_CHECK:
515+
case MX_SCCHECK:
516+
count++;
517+
break;
518+
case MX_SCSTRING:
519+
count++;
520+
break;
521+
}
522+
}
523+
} while (!(tree[obj].ob_flags & OF_LASTOB));
524+
525+
if (count == 0)
526+
return;
527+
528+
uPtr = (USERBLK *)cf_malloc(count * sizeof(USERBLK), "fix_dial", FALSE); /* leaked */
529+
530+
/* 2nd pass: construct USERBLKs */
487531
obj = -1;
488532
do
489533
{
@@ -494,32 +538,37 @@ void fix_dial(OBJECT *tree)
494538
switch (mtyp)
495539
{
496540
case MX_GROUPBOX2:
497-
make_userdef(tree, obj, draw_groupbox);
541+
make_userdef(uPtr, tree, obj, draw_groupbox);
542+
uPtr++;
498543
break;
499544
}
500545

501546
/* den Rest nur, wenn keine WHITEBACK-Buttons verfgbar sind */
502-
/* if ((gl_magx <= 0x200 && gl_naes < 0x0200) || use_all_userdefs) */
503547
if (!mx_buttons || use_all_userdefs)
504548
{
505549
switch (mtyp)
506550
{
507551
case MX_UNDERLINE:
508-
make_userdef(tree, obj, draw_underline);
552+
make_userdef(uPtr, tree, obj, draw_underline);
553+
uPtr++;
509554
break;
510555
case MX_GROUPBOX:
511-
make_userdef(tree, obj, draw_groupbox);
556+
make_userdef(uPtr, tree, obj, draw_groupbox);
557+
uPtr++;
512558
break;
513559
case MX_RADIO:
514560
case MX_SCRADIO:
515-
make_userdef(tree, obj, draw_radiobutton);
561+
make_userdef(uPtr, tree, obj, draw_radiobutton);
562+
uPtr++;
516563
break;
517564
case MX_CHECK:
518565
case MX_SCCHECK:
519-
make_userdef(tree, obj, draw_checkbutton);
566+
make_userdef(uPtr, tree, obj, draw_checkbutton);
567+
uPtr++;
520568
break;
521569
case MX_SCSTRING:
522-
make_userdef(tree, obj, draw_scstring);
570+
make_userdef(uPtr, tree, obj, draw_scstring);
571+
uPtr++;
523572
break;
524573
}
525574
}

wddelete.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ void delete_wdial(WDIALOG *wd)
5454
p->next = wd->next;
5555
}
5656

57-
Mfree(wd);
57+
free(wd);
5858
}
5959
}

0 commit comments

Comments
 (0)