Esempio n. 1
0
void *talloc_atomic_uncollectable__(size_t size, const char *filename, int linenumber){
	void *ret;

	ret=tracker_alloc__(size,GC_malloc_atomic_uncollectable, filename, linenumber);

	if(ret!=NULL) return ret;

#if 0
	if(tmemoryisused==0){
		tmemoryisused=1;
		GC_free(tmemory);
		tmemory=NULL;
	}

#ifndef DISABLE_BDWGC
 	ret=GC_malloc_atomic_uncollectable(size);
#else
	ret=OS_getmem(size);		// For debugging. (wrong use of GC_malloced memory could be very difficult to trace)
#endif

#endif

        RWarning("Out of memory. I'll try to continue by allocating a different way, but you should save and quit now.\n");
        ret = calloc(1,size);
        
	if(ret!=NULL) return ret;


        RWarning("Didn't succeed. Out of memory. Quitting. (atomic_uncollectable allocator)\n");
	ShutDownYepp();
	return NULL;
}
Esempio n. 2
0
static hash_element_t *HASH_get(const hash_t *hash, const char *key, int i, enum DynType type){
  hash_element_t *element=HASH_get_no_complaining(hash, key, i);

  if(element==NULL){
    RWarning("HASH_get. Element not found. key: \"%s\"/%d. hash: %p",key,i,hash);
    return NULL;
  }
  
  if(element->a.type!=type){
    RWarning("HASH_get. Element \"%s\"/%d is found, but is wrong type. Requested %s, found %s.",key,i,DYN_type_name(type),DYN_type_name(element->a.type));
    return NULL;
  }

  return element;
}
Esempio n. 3
0
char *GFX_ReadStringFromPythonCommand(char *pythoncommand){
  FILE *file;
  char filename[50];
  char temp[strlen(pythoncommand)+500];
  char *ret=talloc_atomic(strlen(pythoncommand)+500);
  ret[0] = '\0';

  sprintf(filename,"/tmp/radiumipctempfileXXXXXX");
  int x1 = mkstemp(filename);
  (void)x1;

  sprintf(temp,pythoncommand,filename);


  PyRun_SimpleString(temp);


  file=fopen(filename,"r");
  if(file==NULL) {
    RError("GFX_ReadStringFromPythonCommand: File is null -%s-.\n",filename);
    return ret;
  }

  void* x2 = fgets(ret,strlen(pythoncommand)+499,file);
  fclose(file);
  (void)x2;

  printf("Tried to read -%s-\n",ret);
  sprintf(temp,"rm %s",filename);
  if(system(temp)==-1)
    RWarning("Unable to delete \"%s\"",filename);
  
  return ret;
}
Esempio n. 4
0
// Note that 'y' can be outside the range of the nodeline. If that happens, nodelines is not modified.
static void insert_nonnode_nodeline(struct NodeLine *nodelines, const struct ListHeader3 *element, float y){

  if(y <= nodelines->y1)
    return;

  while(nodelines != NULL) {
    if(y>nodelines->y1 && y<nodelines->y2){

      // put it after

      struct NodeLine *n = (struct NodeLine *)talloc(sizeof(struct NodeLine));
      n->element1 = element;
      n->y1 = y;

      n->x1 = scale(GetfloatFromPlace(&element->p),
                    GetfloatFromPlace(&nodelines->element1->p),
                    GetfloatFromPlace(&nodelines->element2->p),
                    nodelines->x1, nodelines->x2
                    );

      //n->x1 = scale(y, nodelines->y1, nodelines->y2, nodelines->x1, nodelines->x2);

      n->next = nodelines->next ;
      nodelines->next = n;

      n->x2 = nodelines->x2;
      n->y2 = nodelines->y2;
      if (n->y2 < n->y1) {
        RWarning("y2 < y1: %f < %f",n->y2,n->y1);
        n->y2 = n->y1;
      }
      n->element2 = nodelines->element2;

      nodelines->x2 = n->x1;
      nodelines->y2 = n->y1;
      if (nodelines->y2 < nodelines->y1) {
        RWarning("y2 < y1: %f < %f",nodelines->y2,nodelines->y1);
        nodelines->y2 = nodelines->y1;
      }
      nodelines->element2 = n->element1;

      return;
    }

    nodelines = nodelines->next;
  }
}
Esempio n. 5
0
/************************************************************
   FUNCTION
     Does never return NULL.
     Clears memory.
************************************************************/
void *talloc__(size_t size, const char *filename, int linenumber){ ///, const char *filename, int linenumber){
	void *ret;

	ret=tracker_alloc__(size,GC_malloc, filename, linenumber);

	if(ret!=NULL) return ret;

        RWarning("Out of memory. Trying to get memory a different way. You should save and quit.");

        ret=calloc(1,size);
	if(ret!=NULL) return ret;


	RWarning("\n\n\n Didn't succeed. OUT OF MEMORY. Have to quit\n\n\n");
	ShutDownYepp();
	return NULL;
}
Esempio n. 6
0
static double get_number(const hash_t *hash, const char *key, int i){
  hash_element_t *element=HASH_get_no_complaining(hash, key, i);

  if(element==NULL){
    RWarning("HASH_get_number. Element not found. key: \"%s\"/%d. hash: %p",key,i,hash);
    return 0.0;
  }

  if(element->a.type==INT_TYPE)
    return element->a.int_number;
  else if (element->a.type==FLOAT_TYPE)
    return element->a.float_number;


  RWarning("HASH_get. Element \"%s\"/%d is found, but is wrong type. Requested a number, found %s.",key,i,DYN_type_name(element->a.type));
  return 0.0;
}
Esempio n. 7
0
static dyn_t get_dyn(const hash_t *hash, const char *key, int i){
  hash_element_t *element=HASH_get_no_complaining(hash, key, i);

  if(element==NULL){
    RWarning("HASH_get_dyn. Element not found. key: \"%s\"/%d. hash: %p",key,i,hash);
    return DYN_create_bool(false);
  }

  return element->a;
}
Esempio n. 8
0
static void recreate_from_state(struct SoundPlugin *plugin, hash_t *state){
  const wchar_t *filename = HASH_get_string(state, "filename");
  int         bank_num    = HASH_get_int(state, "bank_num");
  int         preset_num  = HASH_get_int(state, "preset_num");

  if(filename==NULL)
    return;

  if(FLUIDSYNTH_set_new_preset(plugin, filename, bank_num, preset_num)==false)
    RWarning("Could not load soundfont \"%s\", bank %d, preset %d",filename,bank_num,preset_num);
}
Esempio n. 9
0
int PLAYER_get_block_delta_time(struct SeqTrack *seqtrack, STime time){
  g_last_seq_time_converted_to_delta_time = time;
  
  if(time<seqtrack->start_time || time>seqtrack->end_time) // time may be screwed up if not coming from the player.
    return 0;

  if(is_playing()){
    //int ret = ((time - seqtrack->start_time) * pc->reltime / (seqtrack->end_time - seqtrack->start_time)); // i.e. "scale(time, seqtrack->start_time, seqtrack->end_time, 0, pc->reltime)"
    int ret = ((time - seqtrack->start_time) * RADIUM_BLOCKSIZE / (seqtrack->end_time - seqtrack->start_time)); // i.e. "scale(time, seqtrack->start_time, seqtrack->end_time, 0, RADIUM_BLOCKSIZE)"
    if(ret<0){
      RWarning("ret<0: %d",ret);
      return 0;
    }
    //if(ret>=pc->reltime){
    if(ret>=RADIUM_BLOCKSIZE){
      RWarning("ret>pc->reltime: %d > %d",ret,RADIUM_BLOCKSIZE);
      return (int)RADIUM_BLOCKSIZE-1;
    }
    return ret;
  }else
    return 0;
}
Esempio n. 10
0
static void recreate_from_state(struct SoundPlugin *plugin, hash_t *state){
  const wchar_t *filename          = HASH_get_string(state, "filename");
  int            instrument_number = HASH_get_int(state, "instrument_number");
  int            resampler_type    = HASH_get_int(state, "resampler_type");

  if(filename==NULL){
    RError("filename==NULL");
    return;
  }

  if(set_new_sample(plugin,filename,instrument_number,resampler_type)==false)
    RWarning("Could not load soundfile \"%s\". (instrument number: %d)\n",STRING_get_chars(filename),instrument_number);
}
Esempio n. 11
0
static QColor get_replacement_color(enum ColorNums colornum){
  int i=0;
  while(g_replacement_color[i].num != END_CONFIG_COLOR_NUM){
    if (g_replacement_color[i].num==colornum)
      return g_replacement_color[i].color;
    i++;
  }

  RWarning("Unable to find color %s in config file", get_color_config(colornum).config_name);

  QColor ret;  
  return ret;
}
Esempio n. 12
0
static bool get_bool(const hash_t *hash, const char *key, int i){
  hash_element_t *element=HASH_get_no_complaining(hash, key, i);

  if(element==NULL){
    RWarning("HASH_get_bool. Element not found. key: \"%s\"/%d. hash: %p",key,i,hash);
    return false;
  }
  
  if(element->a.type==BOOL_TYPE)
    return element->a.bool_number;

  // Before v3, BOOL_TYPE was saved to disk as integers. Unfortunatly, we can't check the value of hash->version since we don't save old hash types, meaning that this info is lost when loading old song, saving it, and loading it again.
  if(element->a.type==INT_TYPE){
    if (element->a.int_number==0)
      return false;
    if (element->a.int_number==1)
      return true;
  }

  RWarning("HASH_get. Element \"%s\"/%d is found, but is wrong type. Requested BOOL_TYPE, found %s.",key,i,DYN_type_name(element->a.type));

  return false;
}
Esempio n. 13
0
size_t utf8Length(byte *string, size_t sizeInBytes) {
    rbool  isValid = 0;
    size_t length  = 0;
    size_t nextPosition = 0;
    unsigned codePoint = 0;

    while (utf8GetNextCharacter(string, sizeInBytes, &nextPosition, &isValid, &codePoint)) {
        ++length;
    }
    ifWarning(!isValid,
              RWarning("RString. Utf-8 encoding not valid.", (pointer) string)
    );

    return length;
}
Esempio n. 14
0
static char *MIDIGetPatchData(struct Patch *patch, char *key){
  if(false){

  }else if(!strcasecmp(key,"port")){
    return getPatchData(patch)->midi_port->name;

  }else if(!strcasecmp(key,"channel")){
    return talloc_numberstring(getPatchData(patch)->channel);

  }else if(!strcasecmp(key,"LSB")){
    return talloc_numberstring(getPatchData(patch)->LSB);

  }else if(!strcasecmp(key,"MSB")){
    return talloc_numberstring(getPatchData(patch)->MSB);

  }else if(!strcasecmp(key,"preset")){
    return talloc_numberstring(getPatchData(patch)->preset);

  } else
    RWarning("MIDIGetPatchData: Unknown key \"%s\" for midi instrument", key);

  return "";
}
Esempio n. 15
0
static enum ColorNums newFXColor(void){  
  static enum ColorNums last = AUTOMATION8_COLOR_NUM;
  
  switch(last) {
    
    case AUTOMATION1_COLOR_NUM:
      last = AUTOMATION2_COLOR_NUM;
      return last;
    case AUTOMATION2_COLOR_NUM:
      last = AUTOMATION3_COLOR_NUM;
      return last;
    case AUTOMATION3_COLOR_NUM:
      last = AUTOMATION4_COLOR_NUM;
      return last;
    case AUTOMATION4_COLOR_NUM:
      last = AUTOMATION5_COLOR_NUM;
      return last;
    case AUTOMATION5_COLOR_NUM:
      last = AUTOMATION6_COLOR_NUM;
      return last;
    case AUTOMATION6_COLOR_NUM:
      last = AUTOMATION7_COLOR_NUM;
      return last;
    case AUTOMATION7_COLOR_NUM:
      last = AUTOMATION8_COLOR_NUM;
      return last;
    case AUTOMATION8_COLOR_NUM:
      last = AUTOMATION1_COLOR_NUM;
      return last;
      
    default:
      RWarning("Unknown last color %d\n",last);
      last = AUTOMATION1_COLOR_NUM;
      return last;
      
  }
}
Esempio n. 16
0
void showWarning(char *text){
  RWarning(text);
}
Esempio n. 17
0
STime getBlockSTimeLength(const struct Blocks *block){
  if (block->num_lines != block->num_time_lines)
    RWarning("block->num_lines != block->num_time_lines: %d != %d",block->num_lines, block->num_time_lines);
    
  return block->times[block->num_time_lines].time;
}
Esempio n. 18
0
void GFXS_TextType(
	     void (*GFX_OSFunc)(
				struct Tracker_Windows *window,
				int color,const char *text,
				int x,int y,
                                int width,
                                int flags,
                                int where
				),
	     struct Tracker_Windows *window,
	     int color,const char *text,
	     int x,int y,
             int width,
             int flags,
             int where
	     )
{
  if(text==NULL){
    RWarning("text==NULL\n");
    return;
  }
  if(flags & TEXT_NOTEXT){
    int len=strlen(text);
    int maxx=window->wblock->t.x2;
    int glen=len*window->fontwidth;

    if(x>=maxx) return;

    if(GFXS_EnsureBoundaries(window,"GFXS_TextType NOTEXT",x,y,x,y)==false){
      return;
    }

    if(x+glen>=maxx){
      len=(maxx-x-1)/window->fontwidth;
    }

    if(GFXS_EnsureBoundaries(window,"GFXS_TextType NOTEXT2",x,y,x,y)==false){
      return;
    }
    
    (*GFX_OSFunc)(window,color,text,x,y,width,flags,where);
    
  }else{

    int maxx=window->wblock->t.x2;
    int len=strlen(text);
    int glen=len*window->fontwidth;
    char *to;
    int newlen;
    
    if(x>=maxx) return;
    
    if(GFXS_EnsureBoundaries(window,"GFXS_TextType",x,y,x,y)==false){
      return;
    }

    to=talloc_strdup(text);
    
    if(x+glen>=maxx){
      newlen=(maxx-x-1)/window->fontwidth;
      to[newlen]=0;
    }

    if(GFXS_EnsureBoundaries(window,"GFXS_TextType",x,y,x,y)==false){
      return;
    }

    (*GFX_OSFunc)(window,color,(const char*)to,x,y,width,flags,where);
  }
}
Esempio n. 19
0
static const struct NodeLine *create_nodelines(
                                        const struct Tracker_Windows *window,
                                        const struct WBlocks *wblock,
                                        const struct ListHeader3 *list,                                  
                                        float (*get_x)(const struct WBlocks *wblock, const struct ListHeader3 *element, int *logtype), // should return a value between 0 and 1.
                                        const struct ListHeader3 *last_element // may be null. may also contain more than one element.
                                        )
{
  struct NodeLine *nodelines = NULL;

  R_ASSERT(list != NULL);
  R_ASSERT(list->next != NULL || last_element!=NULL);

  if (last_element!=NULL){
    const Place *start = &list->p;
    const Place *end = &last_element->p;
    R_ASSERT(PlaceGreaterThan(end, start));
  }
  
  // 1. Create straight forward nodelines from the list
  {
    float reallineF = 0.0f;
    struct NodeLine *nodelines_last = NULL;

    while(list != NULL){
      struct NodeLine *nodeline = (struct NodeLine *)talloc(sizeof(struct NodeLine));

      nodeline->x1 = get_x(wblock, list, &nodeline->logtype);
      reallineF = FindReallineForF(wblock, reallineF, &list->p);
      nodeline->y1 = get_realline_y(window, reallineF);
      nodeline->element1 = list;
      nodeline->is_node = true;

      if(nodelines_last==NULL)
        nodelines = nodelines_last = nodeline;
      else {
        nodelines_last->next = nodeline;
        nodelines_last = nodeline;
      }

      list = list->next;
      if (list==NULL) {
        list = last_element;
        last_element = NULL;
      }
    }
  }


  // 2. Insert x2, y2 and element2 attributes, and remove last element.
  {
    R_ASSERT_RETURN_IF_FALSE2(nodelines!=NULL, NULL); // shouldn't be possible, but I got a crash report that indicates that this might have happened.
    R_ASSERT_RETURN_IF_FALSE2(nodelines->next!=NULL, NULL); // shouldn't be possible either, but more likely than the line above.

    struct NodeLine *ns = nodelines;
    struct NodeLine *next = ns->next;
    
    for(;;){
      ns->x2 = ns->logtype==LOGTYPE_HOLD ? ns->x1 : next->x1;
      ns->y2 = next->y1;

      if (ns->y2 < ns->y1) {
        RWarning("y2 < y1: %f < %f",ns->y2,ns->y1);
        ns->y2 = ns->y1;
      }

      ns->element2 = next->element1;
      if(next->next==NULL)
        break;
      ns = next;
      next = next->next;
    }
    ns->next = NULL; // Cut the last element
  }


  // 3. Insert all non-node break-points. (caused by realline level changes)
  {
    struct LocalZooms **reallines=wblock->reallines;
    int curr_level = reallines[0]->level;
    int realline;
    float reallineF = 0.0f;
    
    for(realline = 1; realline < wblock->num_reallines ; realline++) {
          
      struct LocalZooms *localzoom = reallines[realline];
      
      if (localzoom->level != curr_level){
        reallineF = FindReallineForF(wblock, reallineF, &localzoom->l.p);
        insert_nonnode_nodeline(nodelines, &localzoom->l, get_realline_y(window, reallineF));
        curr_level = localzoom->level;
      }
    }
  }


  return nodelines;
}