Go to Post It really is disconcerting to hear those chains rattling above your head. I think their effect was psychological more than anything else. - Greg Marra [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 11-02-2008, 21:35
CrazyNorman CrazyNorman is offline
Registered User
FRC #1100
 
Join Date: Feb 2008
Location: Northborough, MA
Posts: 2
CrazyNorman is an unknown quantity at this point
Re: Want Malloc on FIRST?

Sorry, I exaggerated when I said that dynamic allocation would be 100% necessary, as dynamic allocation can be written in terms of static allocation (as here). On the other hand, having a dynamic allocation system for certain things can result in cleaner code than without.

For example, lets say that in your autonomous, you want to watch out for nearby obstacles such as robots. When the rangefinder picks them up, you could store their location relative, a time, etc. Then, as objects are no longer detected for a certain amount of time, pass out of range, etc., you delete them. Now, you could have a stack, find the first unused "object", store in it, loop through them, make sure they are within range, mark them as unused, etc.

Of course, now you just wrote a local dynamic allocator for that section of code, and when another part of your code works upon semi-similar principles, you just have to rewrite it again. Yet another chance for duplication, mistakes, and horrors.

On the other hand, you could have a generic allocator which works consistently, and use it everywhere that it results in cleaner code than the custom written stack. Don't use this everywhere, but I'm sorry, static variables everywhere and custom stacks don't necessarily result in more bug- free code.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
malloc? Jake M Programming 5 21-06-2007 21:24
Malloc? interfect Programming 6 05-02-2007 09:15
Do you want to Volunteer with FIRST? dez250 General Forum 13 18-11-2004 10:03
Colleges Want FIRST Students Brandon Martus Announcements 1 11-01-2004 23:50
Malloc, etc... rwaliany Programming 6 05-01-2004 02:18


All times are GMT -5. The time now is 19:10.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi