Breaking News
Design How-To

MATLAB-to-C translation, part 1: Pitfalls and problems

NO RATINGS
Page 1 / 2 Next >
More Related Links
View Comments: Newest First | Oldest First | Threaded View
luc_semeria
User Rank
Rookie
re: MATLAB-to-C translation, part 1: Pitfalls and problems
luc_semeria   12/4/2007 6:19:20 PM
NO RATINGS
Writing C code by hand is very error prone! Your comment is right on. The fact that such a simple example may lead to errors or differences of opinion speaks volume for the need for an automatic translation tool such as Catalytic MCS. The example above assumes memory gets allocated inside of functions. Function callers are then responsible for freeing that memory. The example works like this. The malloc corresponding to "free(sorted)" happens in "my_sort". The free corresponding to "y_out = malloc(...);" happens in the caller of "example1". Finally, "i+=1", "i++" and "i=i+1" are all valid loop increments that should lead to the same assembly code out of today's C compilers.

amigan50
User Rank
Rookie
re: MATLAB-to-C translation, part 1: Pitfalls and problems
amigan50   12/4/2007 2:20:48 PM
NO RATINGS
why i+=1 instead of simply i++? "malloc" without a corresponding "free" and vice versa is a bad idea! you free sorted which was not malloc-ed, and you malloc y_out without freeing it.

Top Comments of the Week
August Cartoon Caption Winner!
August Cartoon Caption Winner!
"All the King's horses and all the KIng's men gave up on Humpty, so they handed the problem off to Engineering."
5 comments
Like Us on Facebook

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)
EE Times on Twitter
EE Times Twitter Feed
Radio
LATEST ARCHIVED BROADCAST
David Patterson, known for his pioneering research that led to RAID, clusters and more, is part of a team at UC Berkeley that recently made its RISC-V processor architecture an open source hardware offering. We talk with Patterson and one of his colleagues behind the effort about the opportunities they see, what new kinds of designs they hope to enable and what it means for today’s commercial processor giants such as Intel, ARM and Imagination Technologies.
Flash Poll