delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/05/13/08:57:45

Date: Thu, 13 May 1993 15:16:19 +0200
Conversion: Prohibited
From: <phc27 AT rz DOT uni-kiel DOT dbp DOT de>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: BCC2GRX: new __gr_set_up_modes()

Hi,

again Wonkoo is right. There is a memory waste in the BCC2GRX v1.1 library.
You should replace the src/bccgrx.c __gr_set_up_modes()
with the following code:

void __gr_set_up_modes(void)
{
  GR_DRIVER_MODE_ENTRY *tm, *gm;
  int mode;
  static int DidInit = FALSE;

  if (__gr_INIT || DidInit) return;
  MM = -1;

  GrSetMode( GrCurrentMode());                       /* Init grx */
  GrGetDriverModes(&tm, &__gr_DATA);
  if (__gr_DATA == NULL) {
    __gr_modeindx = NULL;
    MM = 0;
    return;
  }
  gm = __gr_DATA;
  mode = 1;
  while (gm->width != 0) {
    if (gm->BIOS_mode != 0xFF)
      ++mode;
    gm += 1;
  }
  __gr_modeindx = (short *) malloc(sizeof(short) * mode);
  if (__gr_modeindx == NULL) {
    ERR = grError;
    return;
  }
  gm = __gr_DATA;
  __gr_modeindx[0] = -1;  /* GR_default_graphics */
  mode = 1;
  while (gm->width != 0) {
    if (gm->BIOS_mode != 0xFF)
      __gr_modeindx[mode++] = gm-__gr_DATA;
    gm += 1;
  }
  MM = mode - 1;
  DidInit = TRUE;
}

The memory will be allocated only once now.

The whole initialisation of the BCC2GRX was reorganised stepping tom 1.0 to
1.1 . It wasn't ready when it reached public and isn't ready until now
(I'm very busy at the moment :-( ). I decided to give it away to overcome
the 256 color problem with 1.0 release.

I hope this patch helps you Wonkoo.

Hartmut



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019