Ignore:
Timestamp:
Mar 22, 2008, 10:39:25 AM (15 years ago)
Author:
Sam Hocevar
Message:
  • Get rid of jmalloc and replace it with standard malloc. Modern operating systems certainly perform a lot better than this custom implementation, and we have superior tools (eg. valgrind) to debug and profile memory usage without interfering with the code itself.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/imlib/specs.cpp

    r124 r129  
    2525#include "specs.hpp"
    2626#include "system.h"
    27 #include "jmalloc.hpp"
    2827#include "dprint.hpp"
    2928
     
    7574    if( spec_prefix )
    7675    {
    77         jfree( spec_prefix );
     76        free( spec_prefix );
    7877    }
    7978   
    8079    if( prefix )
    8180    {
    82         spec_prefix = strcpy( (char *)jmalloc( strlen( prefix ) + 2, "prefix_name" ), prefix );
     81        spec_prefix = strcpy( (char *)malloc( strlen( prefix ) + 2 ), prefix );
    8382        int len = strlen( prefix );
    8483        if( prefix[len - 1] != '\\' && prefix[len - 1] != '/')
     
    104103    if( save_spec_prefix )
    105104    {
    106         jfree( save_spec_prefix );
     105        free( save_spec_prefix );
    107106    }
    108107
     
    110109    {
    111110        int len = strlen( save_prefix );
    112         save_spec_prefix = (char *)jmalloc( len + 1, "prefix_name" );
     111        save_spec_prefix = (char *)malloc( len + 1 );
    113112        strcpy( save_spec_prefix, save_prefix );
    114113/* AK - Commented this out as it may cause problems
     
    143142{
    144143  rbuf_size=8192;
    145   rbuf=(unsigned char *)jmalloc(rbuf_size,"File read buffer");
     144  rbuf=(unsigned char *)malloc(rbuf_size);
    146145  rbuf_start=rbuf_end=0;
    147146
    148147  wbuf_size=8192;
    149   wbuf=(unsigned char *)jmalloc(wbuf_size,"File write buffer");
     148  wbuf=(unsigned char *)malloc(wbuf_size);
    150149  wbuf_end=0;
    151150}
     
    153152bFILE::~bFILE()
    154153{
    155   if (rbuf) jfree(rbuf);
     154  if (rbuf) free(rbuf);
    156155  flush_writes();
    157   if (wbuf) jfree(wbuf);
     156  if (wbuf) free(wbuf);
    158157}
    159158
     
    268267  rbuf_start=rbuf_end=0;
    269268  if (rbuf)
    270     jfree(rbuf);
     269    free(rbuf);
    271270  rbuf_size=size;
    272   rbuf=(unsigned char *)jmalloc(rbuf_size,"File buffer");
     271  rbuf=(unsigned char *)malloc(rbuf_size);
    273272}
    274273
     
    645644  if (total)
    646645  {
    647     jfree(data);
    648     jfree(entries);
     646    free(data);
     647    free(entries);
    649648  }
    650649}
     
    754753  {
    755754    total=fp->read_uint16();
    756     entries=(spec_entry **)jmalloc(sizeof(spec_entry *)*total,"spec_directory::entries");
     755    entries=(spec_entry **)malloc(sizeof(spec_entry *)*total);
    757756    long start=fp->tell();
    758757
     
    768767      size+=entry_size;
    769768    }
    770     data=jmalloc(size,"spec_directory::data");
     769    data=malloc(size);
    771770    char *dp=(char *)data;
    772771    fp->seek(start,SEEK_SET);
     
    972971    for (;i<total;i++)                               // compact the pointer array
    973972      entries[i]=entries[i+1];
    974     entries=(spec_entry **)jrealloc(entries,sizeof(spec_entry *)*total,"spec_directory::entries");
     973    entries=(spec_entry **)realloc(entries,sizeof(spec_entry *)*total);
    975974  }
    976975  else
     
    983982{
    984983  total++;
    985   entries=(spec_entry **)jrealloc(entries,sizeof(spec_entry *)*total,"spec_directory::entries");
     984  entries=(spec_entry **)realloc(entries,sizeof(spec_entry *)*total);
    986985  entries[total-1]=e;
    987986}
     
    994993
    995994  if (total)
    996     jfree(entries);
     995    free(entries);
    997996}
    998997
Note: See TracChangeset for help on using the changeset viewer.