FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-31-2003, 07:38 AM
J-Wing
Guest
 
Posts: n/a
Default dynamic memory allocation NIOS

i am using dynamic memory allocation to run in NIOS.
i) this means using malloc to get the memory needed
ii) and using free to free the memory needed

after testing, i think that the free function does not do anything. is
there any way to free the memory allocated?
Reply With Quote
  #2 (permalink)  
Old 01-05-2004, 10:49 PM
Jesse Kempa
Guest
 
Posts: n/a
Default Re: dynamic memory allocation NIOS

[email protected] (J-Wing) wrote in message news:<[email protected] com>...
> i am using dynamic memory allocation to run in NIOS.
> i) this means using malloc to get the memory needed
> ii) and using free to free the memory needed
>
> after testing, i think that the free function does not do anything. is
> there any way to free the memory allocated?


Hi J-Wing,

I have not had problems using malloc or free on Nios. I created the
following test code which shows malloc and free operating correctly.
Note that I am attempting to allocate slightly over 1MB of memory; in
this test I am only using SRAM on my Nios board, with is 1MB. If I
comment out the free(buff) line, malloc() will fail as the memory is
filled. When free(buff) is still in place, all malloc() operations
complete with success.

Jesse Kempa
Altera Corp.
jkempa at altera dot com

===== Nios/malloc/free example code =====

#include "excalibur.h"

int main(void)
{
int i=0, result=0, goodmallocs=0;
unsigned char *buff;

for(i=0; i< 1030; i++)
{
buff = (unsigned char *) malloc(1024);

if(buff)
goodmallocs++;
else
printf("error mallocing at i=%d\n", i);

free(buff);
}
printf("I was able to malloc() %d 1024-byte blocks. Bye.\n",
goodmallocs);

return 0;
}

=========================
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory map for Nios Maxlim FPGA 0 08-06-2003 05:33 PM


All times are GMT +1. The time now is 07:08 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved