Beispiel #1
0
/**********************************************************************
 * save_best_state
 *
 * Save this state away to be compared later.
 **********************************************************************/
void save_best_state(CHUNKS_RECORD *chunks_record) {
  STATE state;
  SEARCH_STATE chunk_groups;
  int num_joints;

  if (save_priorities) {
    num_joints = chunks_record->ratings->dimension() - 1;

    state.part1 = 0xffffffff;
    state.part2 = 0xffffffff;

    chunk_groups = bin_to_chunks (&state, num_joints);
    display_segmentation (chunks_record->chunks, chunk_groups);
    memfree(chunk_groups);

    cprintf ("Enter the correct segmentation > ");
    fflush(stdout);
    state.part1 = 0;
    scanf ("%x", &state.part2);

    chunk_groups = bin_to_chunks (&state, num_joints);
    display_segmentation (chunks_record->chunks, chunk_groups);
    memfree(chunk_groups);
    window_wait(segm_window);  /* == 'n') */

    if (known_best_state)
      free_state(known_best_state);
    known_best_state = new_state (&state);
  }
}
Beispiel #2
0
void thread_deregister( pthread_t pthreadId )
{
    BalancedBTreeItem_t    *item;
    Thread_t               *thread;

    item = BalancedBTreeFind( ThreadTree, (void *)&pthreadId, UNLOCKED, FALSE );
    if( !item ) {
        return;
    }

    BalancedBTreeRemove( ThreadTree, item, UNLOCKED, TRUE );
    thread = (Thread_t *)item->item;

    LogPrint( LOG_INFO, "Removed Thread %ld as \"%s\"", pthreadId, 
                        (char *)thread->name );

    if( thread->callbacks ) {
        memfree( thread->callbacks );
    }
    memfree( thread );
    memfree( item );

    if( !pthread_equal( pthread_self(), pthreadId ) ) {
        pthread_join( pthreadId, NULL );
    }
}
Beispiel #3
0
void close_file(struct file_info *fi)
{
    if (fi->f != NULL)
        fclose(fi->f);
    memfree(fi->name);
    memfree(fi);
}
/*-----------------------------------------------------------------------------*/
void CleanUpUnusedData(
    LIST ProtoList)
{
  PROTOTYPE* Prototype;

  iterate(ProtoList)
  {
    Prototype = (PROTOTYPE *) first_node (ProtoList);
    if(Prototype->Variance.Elliptical != NULL)
    {
      memfree(Prototype->Variance.Elliptical);
      Prototype->Variance.Elliptical = NULL;
    }
    if(Prototype->Magnitude.Elliptical != NULL)
    {
      memfree(Prototype->Magnitude.Elliptical);
      Prototype->Magnitude.Elliptical = NULL;
    }
    if(Prototype->Weight.Elliptical != NULL)
    {
      memfree(Prototype->Weight.Elliptical);
      Prototype->Weight.Elliptical = NULL;
    }
  }
}
Beispiel #5
0
static struct file_info *open_file(char *name)
{
    struct file_info *fi = memalloc(sizeof(*fi));

    fi->line = 1;

    if (name[0] != '/') {
        char *path;
        if ((path = getcwd(NULL, 0)) == NULL)
            err(1, NULL);
        fi->name = memalloc(strlen(path) + strlen(name) + 2);
        sprintf(fi->name, "%s/%s", path, name);
        free(path);
        if ((fi->f = fopen(fi->name, "r")) == NULL) {
            memfree(fi->name);
            fi->name = memalloc(strlen(DEF_DIR) + strlen(name) + 2);
            sprintf(fi->name, "%s/%s", DEF_DIR, name);
            fi->f = fopen(fi->name, "r");
        }
    } else {
        fi->name = memalloc(strlen(name) + 1);
        strcpy(fi->name, name);
        fi->f = fopen(fi->name, "r");
    }

    if (fi->f == NULL) {
        memfree(fi->name);
        memfree(fi);
        fi = NULL;
    }

    return fi;
}
/*
 * don't do any of "storage compaction" nonsense, "just" the three modes:
 *   + cp == NULL ==> malloc
 *   + nbytes == 0 ==> free
 *   + else ==> realloc
 */
void *
memrealloc(void *cp, size_t nbytes)
{   
	union overhead *op;
  	size_t size;
	size_t alignpad;
	void *np;

	if (cp == NULL)
		return memalloc(nbytes, 8);

	if (nbytes == 0) {
		memfree(cp);
		return NULL;
	}

	op = ((union overhead *)cp)-1;
  	size = op->ov_index;
	alignpad = op->ov_alignpad;

	/* don't bother "compacting".  don't like it?  don't use realloc! */
	if (((1<<(size+MINSHIFT)) - (alignpad+sizeof(*op))) >= nbytes)
		return cp;

	/* we're gonna need a bigger bucket */
	np = memalloc(nbytes, 8);
	if (np == NULL)
		return NULL;

	memcpy(np, cp, (1<<(size+MINSHIFT)) - (alignpad+sizeof(*op)));
	memfree(cp);
	return np;
}
Beispiel #7
0
/**
 * 送信
 *
 * @param[in] sockfd ソケット
 * @param[in] sbuf 送信バッファ
 * @param[in] length バイト数
 * @retval EX_NG エラー
 */
static int
send_client(int sockfd, uchar *sbuf, size_t length)
{
    struct client_data *cdata = NULL; /* 送信データ構造体 */
    ssize_t slen = 0;                 /* 送信データバイト数 */
    int retval = 0;                   /* 戻り値 */

    dbglog("start");

    /* データ設定 */
    slen = set_client_data(&cdata, sbuf, length);
    if (slen < 0) {
        cut_notify("set_server_data=%zd(%d)", slen, errno);
        return EX_NG;
    }

    /* 送信 */
    retval = send_data(sockfd, cdata, (size_t *)&slen);
    if (retval < 0) {
        cut_notify("send_data: slen=%zd(%d)", slen, errno);
        memfree((void **)&cdata, NULL);
        return EX_NG;
    }
    memfree((void **)&cdata, NULL);
    return EX_OK;
}
Beispiel #8
0
void DoneArtificialIntelligence8 ()
{
    // Likvidace existujicich tabulek
    if (UnAnalyse != NULL) {
        for (int i = 0; i < BADLIFE; i++) {
            if (Units [i] == NULL) continue;
            if (UnAnalyse [i].w0 != NULL) memfree (UnAnalyse [i].w0);
            if (UnAnalyse [i].w1 != NULL) memfree (UnAnalyse [i].w1);
            if (UnAnalyse [i].w2 != NULL) memfree (UnAnalyse [i].w2);
            if (UnAnalyse [i].w3 != NULL) memfree (UnAnalyse [i].w3);
        }
        memfree (UnAnalyse);
        UnAnalyse = NULL;
    }
    
    if (Army1 != NULL) {delete Army1; Army1 = NULL; }
    if (Army2 != NULL) {delete Army2; Army2 = NULL; }
    if (Army3 != NULL) {delete Army3; Army3 = NULL; }
    if (AirArmy3 != NULL) {delete AirArmy3; AirArmy3 = NULL; }
    if (Army4 != NULL) {delete Army4; Army4 = NULL; }
    if (Army5 != NULL) {delete Army5; Army5 = NULL; }
    if (Army6 != NULL) {delete Army6; Army6 = NULL; }
    if (Army7 != NULL) {delete Army7; Army7 = NULL; }
    if (Army8 != NULL) {delete Army8; Army8 = NULL; }
    if (AirArmy8 != NULL) {delete AirArmy8; AirArmy8 = NULL; }
    if (Marine1 != NULL) {delete Marine1; Marine1 = NULL; }
    if (Marine8 != NULL) {delete Marine8; Marine8 = NULL; }
    if (Towers != NULL) {delete Towers; Towers = NULL; }
}
Beispiel #9
0
void SSrelease (Setsetp ss)
{
  int i;

  for (i = 0; i < ss->nsets; i++)
    memfree ((char*)ss->sets[i]);
  memfree ((char*)ss);
}
Beispiel #10
0
/**
 * @brief Thread to handle WebService requests
 * @return never returns until shutdown
 *
 * Receives requests over a web socket and acts on them.
 */
void *WebServiceThread( void *arg )
{
    char               *port;
    char               *logdir;
    char                buf[1024];
    char              **options;
    struct mg_context  *ctx;

    pthread_mutex_lock( startupMutex );

    port = pb_get_setting( "webServicePort" );
    if( !port || !atoi(port) ) {
        LogPrintNoArg( LOG_CRIT, "No WebService Port defined.  Aborting!" );
        return;
    }

    logdir = pb_get_setting( "webServiceLogDir" );
    if( !logdir ) {
        logdir = memstrlink( "/tmp" );
    }

    LogPrint( LOG_DEBUG, "Web Service listening on port %s", port );
    LogPrint( LOG_DEBUG, "Web Logs in %s", logdir );

    options = CREATEN(char *, 7);
    options[0] = memstrlink("ports");
    options[1] = memstrdup(port);
    options[2] = memstrlink("access_log");
    sprintf( buf, "%s/access.log", logdir );
    options[3] = memstrdup(buf);
    options[4] = memstrlink("error_log");
    sprintf( buf, "%s/error.log", logdir );
    options[5] = memstrdup(buf);
    options[6] = NULL;

    memfree( port );
    memfree( logdir );

    mg_set_allocs( &webServiceAllocs );

    /*
     * Initialize mongoose context.
     * Start listening on port specified.
     */
    ctx = mg_start(webServiceCallback, NULL, (const char **)options);

    while( !GlobalAbort ) {
        sleep(1);
    }
    
    mg_stop(ctx);

    LogPrintNoArg(LOG_INFO, "Ending WebServiceThread");
    return( NULL );
}
Beispiel #11
0
void TTransBox::Hide(int fast)
{
	MouseHide();
	if (iniEnhancedGuiOn && (!fast))
		for (int i = 0; i < w; i += w/OPEN_STEP) {Draw(i); SDL_Delay(15);}
	PutBitmap32(x, y, Bkg, w, h);
	MouseShow();
	unlockmem(Buf, w * h); unlockmem(Bkg, w * h);
	memfree(Bkg);
	memfree(Buf);
}
Beispiel #12
0
static void *psygnosis_c_track0_write_raw(
    struct disk *d, unsigned int tracknr, struct stream *s)
{
    struct track_info *ti = &d->di->track[tracknr];
    uint16_t dat[V1_METABLK_WORDS+1], raw[2];
    char *ablk, *block;
    unsigned int i, metablk_words, ver;

    init_track_info(ti, TRKTYP_amigados);
    ablk = handlers[TRKTYP_amigados]->write_raw(d, tracknr, s);
    if ((ablk == NULL) || (ti->type != TRKTYP_amigados))
        goto fail;

    for (ver = 1; ver <= 2; ver++) {

        stream_reset(s);

        metablk_words = (ver == 1) ? V1_METABLK_WORDS : V2_METABLK_WORDS;

        while (stream_next_bit(s) != -1) {

            if ((uint16_t)s->word != 0x428a)
                continue;
            ti->data_bitoff = s->index_offset - 15;

            if ((ver == 2) &&
                ((stream_next_bits(s, 16) == -1) ||
                 ((uint16_t)s->word != 0xaaaa)))
                continue;

            for (i = 0; i < (metablk_words + 1); i++) {
                if (stream_next_bytes(s, raw, 4) == -1)
                    break;
                mfm_decode_bytes(bc_mfm_even_odd, 2, raw, &dat[i]);
            }

            if (checksum(&dat[1], metablk_words, ver) != be16toh(dat[0]))
                continue;

            init_track_info(ti, TRKTYP_psygnosis_c_track0);
            ti->len += metablk_words*2;
            ti->total_bits = 105500;
            block = memalloc(ti->len);
            memcpy(block, ablk, 512*11);
            memcpy(&block[512*11], &dat[1], metablk_words*2);
            memfree(ablk);
            return block;
        }
    }

fail:
    memfree(ablk);
    return NULL;
}
Beispiel #13
0
void joypad::free() {
	if (device_ref) {
		IOHIDDeviceUnscheduleFromRunLoop(device_ref, CFRunLoopGetCurrent(), GODOT_JOY_LOOP_RUN_MODE);
	}
	if (ff_device) {
		FFDeviceReleaseEffect(ff_device, ff_object);
		FFReleaseDevice(ff_device);
		memfree(ff_axes);
		memfree(ff_directions);
	}
}
Beispiel #14
0
void end_metrics() {
  if (states_before_best != NULL) {
    memfree(states_before_best);
    memfree(best_certainties[0]);
    memfree(best_certainties[1]);
    memfree(character_widths);
    states_before_best = NULL;
    best_certainties[0] = NULL;
    best_certainties[1] = NULL;
    character_widths = NULL;
  }
}
Beispiel #15
0
static struct container *eadf_open(struct disk *d)
{
    struct disk_header dhdr;
    struct track_header thdr;
    struct disk_info *di;
    struct track_info *ti;
    unsigned int i;

    lseek(d->fd, 0, SEEK_SET);

    read_exact(d->fd, &dhdr, sizeof(dhdr));
    if (strncmp(dhdr.sig, "UAE-1ADF", sizeof(dhdr.sig)))
        return NULL;

    d->di = di = memalloc(sizeof(*di));
    di->nr_tracks = be16toh(dhdr.nr_tracks);
    di->track = memalloc(di->nr_tracks * sizeof(struct track_info));

    for (i = 0; i < di->nr_tracks; i++) {
        ti = &di->track[i];
        read_exact(d->fd, &thdr, sizeof(thdr));
        thdr.type = be16toh(thdr.type);
        if (thdr.type != 1) {
            warnx("Bad track type %u in Ext-ADF", thdr.type);
            goto cleanup_error;
        }
        init_track_info(ti, TRKTYP_raw);
        ti->len = be32toh(thdr.len);
        if (ti->len == 0) {
            init_track_info(ti, TRKTYP_unformatted);
            ti->total_bits = TRK_WEAK;
        } else {
            ti->dat = memalloc(ti->len);
            ti->total_bits = be32toh(thdr.bitlen);
        }
    }

    for (i = 0; i < di->nr_tracks; i++) {
        ti = &di->track[i];
        read_exact(d->fd, ti->dat, ti->len);
    }

    return &container_eadf;

cleanup_error:
    for (i = 0; i < di->nr_tracks; i++)
        memfree(di->track[i].dat);
    memfree(di->track);
    memfree(di);
    d->di = NULL;
    return NULL;
}
Beispiel #16
0
void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const {

	ULONG buf_size = 1024;
	IP_ADAPTER_ADDRESSES* addrs;

	while (true) {

		addrs = (IP_ADAPTER_ADDRESSES*)memalloc(buf_size);
		int err = GetAdaptersAddresses(AF_INET, GAA_FLAG_SKIP_ANYCAST |
									   GAA_FLAG_SKIP_MULTICAST |
									   GAA_FLAG_SKIP_DNS_SERVER |
									   GAA_FLAG_SKIP_FRIENDLY_NAME,
									 NULL, addrs, &buf_size);
		if (err == NO_ERROR) {
			break;
		};
		memfree(addrs);
		if (err == ERROR_BUFFER_OVERFLOW) {
			continue; // will go back and alloc the right size
		};

		ERR_EXPLAIN("Call to GetAdaptersAddresses failed with error " + itos(err));
		ERR_FAIL();
		return;
	};


	IP_ADAPTER_ADDRESSES* adapter = addrs;

	while (adapter != NULL) {

		IP_ADAPTER_UNICAST_ADDRESS* address = adapter->FirstUnicastAddress;
		while (address != NULL) {

			char addr_chr[INET_ADDRSTRLEN];
			SOCKADDR_IN* ipv4 = reinterpret_cast<SOCKADDR_IN*>(address->Address.lpSockaddr);

			IP_Address ip;
			ip.host= *((unsigned long*)&ipv4->sin_addr);


			//inet_ntop(AF_INET, &ipv4->sin_addr, addr_chr, INET_ADDRSTRLEN);

			r_addresses->push_back(ip);

			address = address->Next;
		};
		adapter = adapter->Next;
	};

	memfree(addrs);
};
Beispiel #17
0
/**********************************************************************
 * FreeClassFields
 *
 * Deallocate the memory consumed by subfields of the specified class.
 **********************************************************************/
void FreeClassFields(CLASS_TYPE Class) {
  int i;

  if (Class) {
    if (Class->MaxNumProtos > 0)
      memfree (Class->Prototypes);
    if (Class->MaxNumConfigs > 0) {
      for (i = 0; i < Class->NumConfigs; i++)
        FreeBitVector (Class->Configurations[i]);
      memfree (Class->Configurations);
    }
  }
}
Beispiel #18
0
static void killscreen()
{
	refresh();

	*(int *)0xdff096L=0x0080;
	*(long *)0xdff080L=oldcoplist;
	*(int *)0xdff088L=0;
	*(int *)0xdff096L=0x8080;

	memfree(&chipcop);
	memfree(&chipspr);
	memfree(&bigbloc);

	CloseLibrary(gfxbase);
}
Beispiel #19
0
/**
 * メモリ解放
 *
 * @param[in] calc calcinfo構造体ポインタ
 * @return なし
 */
void
destroy_answer(void *calc)
{
    calcinfo *ptr = (calcinfo *)calc;
    dbglog("start: result=%p", ptr->answer);
    memfree((void **)&ptr->answer, NULL);
}
Beispiel #20
0
STARTUP(void grayinit())
{
	size_t size = 3840*2;
	char *p0, *p1;
	p0 = memalloc(&size, 0); // allocate two contiguous buffers

	if (!p0) goto nomem;
	p1 = p0 + 3840;
	//memset(p0, 0, size);
	memmove(p0, LCD_MEM, 3840);
	//memmove(p1, LCD_MEM, 3840);
	memset(p1, 0, 3840);
	G.lcd.grayplanes[0] = p0;
	G.lcd.grayplanes[1] = p1;

	G.lcd.planes[0] = p0;
	G.lcd.planes[1] = p0;
	G.lcd.planes[2] = p1;
	G.lcd.third = -1;

#if 0
	/* gradient ramp */
	int i;
	for (i = 0; i < 3840; ++i) {
		p0[i] = (i/1920)&1 ? 0x00 : 0xff;
		p1[i] = (i/960)&1 ? 0x00 : 0xff;
	}
#endif

	G.lcd.grayinitialized = 1;
	return;

nomem:
	memfree(p0, 0);
}
Beispiel #21
0
/** Free all of the nodes of a sub tree. */
void FreeSubTree(KDNODE *sub_tree) {
  if (sub_tree != NULL) {
    FreeSubTree(sub_tree->Left);
    FreeSubTree(sub_tree->Right);
    memfree(sub_tree);
  }
}
Beispiel #22
0
/**
 * スレッドメモリ解放ハンドラ
 *
 * @param[in] arg ポインタ
 * @return なし
 * @attention 引数にvoid **型を渡さなければ不正アクセスになる.
 */
static void
thread_memfree(void *arg)
{
    void **ptr = (void **)arg;
    dbglog("start: *ptr=%p, ptr=%p", *ptr, ptr);
    memfree(ptr, NULL);
}
Beispiel #23
0
void QC_AddSharedVar(progfuncs_t *progfuncs, int start, int size)	//fixme: make offset per progs and optional
{
	int ofs;
	unsigned int a;

	if (numshares >= maxshares)
	{
		void *buf;
		buf = shares;
		maxshares += 16;		
		shares = memalloc(sizeof(sharedvar_t)*maxshares);

		memcpy(shares, buf, sizeof(sharedvar_t)*numshares);

		memfree(buf);
	}
	ofs = start;
	for (a = 0; a < numshares; a++)
	{
		if (shares[a].varofs+shares[a].size == ofs)
		{
			shares[a].size += size;	//expand size.
			return;
		}
		if (shares[a].varofs == start)
			return;
	}


	shares[numshares].varofs = start;
	shares[numshares].size = size;
	numshares++;
}
Beispiel #24
0
void scp_send(
    struct scp_handle *scp,
    uint8_t cmd,
    void *dat,
    uint8_t len)
{
    uint8_t *buf = memalloc(len + 3);
    unsigned int i;

    buf[0] = cmd;
    buf[1] = len;
    memcpy(buf + 2, dat, len);
    buf[len + 2] = 0x4a;
    for (i = 0; i < len + 2; i++)
        buf[len + 2] += buf[i];

    write_exact(scp->fd, buf, len + 3);

    if (cmd == SCPCMD_SENDRAM_USB)
        read_exact(scp->fd, dat, 512*1024);

    read_exact(scp->fd, buf, 2);
    if (buf[0] != cmd)
        errx(1, "Mismatch command echo: sent %02x (%s), received %02x (%s)",
             cmd, scp_cmdstr(cmd), buf[0], scp_cmdstr(buf[0]));
    if (buf[1] != 0x4f)
        errx(1, "Command %02x (%s) failed: %02x (%s)",
             cmd, scp_cmdstr(cmd), buf[1], scp_errstr(buf[1]));


    memfree(buf);
}
Beispiel #25
0
uint32_t mem_alloc(struct amiga_state *s, struct memory *m, uint32_t bytes)
{
    uint32_t addr;
    struct region *r, **pprev;

    regions_dump(m->free);

    pprev = &m->free;
    while (((r = *pprev) != NULL) && ((r->end - r->start + 1) < bytes))
        pprev = &r->next;

    if (r == NULL)
        return 0;

    addr = r->start;
    r->start += bytes;
    if (r->start > r->end) {
        ASSERT(r->start == (r->end + 1));
        *pprev = r->next;
        memfree(r);
    }

    regions_dump(m->free);

    return addr;
}
int main(int argc, char **argv)
{
        int fd_v4l;
	quitflag = 0;

	pthread_t sigtid;
	sigemptyset(&sigset);
	sigaddset(&sigset, SIGINT);
	pthread_sigmask(SIG_BLOCK, &sigset, NULL);
	pthread_create(&sigtid, NULL, (void *)&signal_thread, NULL);

        if (process_cmdline(argc, argv) < 0) {
                return -1;
        }

        fd_v4l = v4l_capture_setup();
	if (g_mem_type == V4L2_MEMORY_USERPTR)
		if (memalloc(g_frame_size, TEST_BUFFER_NUM) < 0) {
			close(fd_v4l);
		}

	v4l_capture_test(fd_v4l);

	if (g_mem_type == V4L2_MEMORY_USERPTR)
		memfree(g_frame_size, TEST_BUFFER_NUM);

	return 0;
}
Beispiel #27
0
/**
 * atexit登録関数
 *
 * @return なし
 */
static void
exit_memfree(void)
{
    memfree((void **)&expr,
            (void **)&sdata,
            (void **)&answer, NULL);
}
Beispiel #28
0
void TToweredTrainUnit::Draw()
{
    TField *f = GetField(X, Y);
    TSprite *s, *sst;
    int rrx = GetRelX(X), rry = GetRelY(Y);
    int drawx = 28 * (rrx - rry) + LittleX + 28;
    int drawy = 14 * (rrx + rry - (f->Height)) + LittleY + 14;
    
    if ((!SelectCrossLock) && (SelectedUnit == this)) {
        void *oldb = MapBuf;
        MapBuf = FullBuf;
        DrawL2Selector(drawx-LittleX, drawy+28-LittleY, f->Terrain, BmpSelected);
        MapBuf = oldb;
  }

    s = GetSprite();
    DrawSprite(drawx, drawy, s);
    if (ActualSprite < 8/*tj.jsme v rovine*/) {
        s = UnitsSprites[Type][40 + WpnOrient];
        DrawSprite(drawx + SpriteLocators[Type][SpriteOrient*2], 
                   drawy + SpriteLocators[Type][SpriteOrient*2+1], s);
    }

    s = GetSmoke();
    if (s) DrawSprite(drawx, drawy, s);

    if (iniShowStatusbar && (!StatusbarLock)) {
        if ((sst = GetStatusBar()) != NULL) {
            DrawSprite(drawx, drawy, sst);
            memfree(sst);
        }
    }
    GetDrawRect(&(LD_rect[ID])); LD_used[ID] = TRUE;
}
Beispiel #29
0
void mem_free(struct amiga_state *s, uint32_t addr, uint32_t bytes)
{
    struct memory *m = find_memory(s, addr, bytes);
    struct region *r, *prev, **pprev;

    ASSERT(m != NULL);

    regions_dump(m->free);

    pprev = &m->free;
    while (((r = *pprev) != NULL) && (r->end < addr))
        pprev = &r->next;

    if ((r != NULL) && (r->start == (addr + bytes))) {
        r->start -= bytes;
    } else {
        r = memalloc(sizeof(*r));
        r->start = addr;
        r->end = addr + bytes - 1;
        r->next = *pprev;
        *pprev = r;
    }

    prev = container_of(pprev, struct region, next);
    if ((pprev != &m->free) && (prev->end >= (addr-1))) {
        ASSERT(prev->end == (addr-1));
        prev->end = r->end;
        prev->next = r->next;
        memfree(r);
    }

    memset(&m->dat[addr - m->start], 0xaa, bytes);

    regions_dump(m->free);
}
Beispiel #30
0
string_t PR_AllocTempStringLen			(progfuncs_t *progfuncs, char **str, unsigned int len)
{
	char **ntable;
	int newmax;
	int i;

	if (!str)
		return 0;

	if (prinst->numtempstrings == prinst->maxtempstrings)
	{
		newmax = prinst->maxtempstrings += 1024;
		prinst->maxtempstrings += 1024;
		ntable = memalloc(sizeof(char*) * newmax);
		memcpy(ntable, prinst->tempstrings, sizeof(char*) * prinst->numtempstrings);
		prinst->maxtempstrings = newmax;
		if (prinst->tempstrings)
			memfree(prinst->tempstrings);
		prinst->tempstrings = ntable;
	}

	i = prinst->numtempstrings;
	if (i == 0x10000000)
		return 0;

	prinst->numtempstrings++;

	prinst->tempstrings[i] = memalloc(len);
	*str = prinst->tempstrings[i];

	return (string_t)((unsigned int)i | 0x40000000);
}