View Single Post
  #1   Spotlight this post!  
Unread 12-02-2008, 01:05
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Dynamic Memory Allocation Woes

Hello,

For hybrid, we're using encoders on our drive train as well as various other sensors to place ourselves on an imaginary (x,y) coordinate grid on the field.

I have created code that allows you to store a list of points. It consists of a structure with two values (x and y) as well as a pointer to point to the next structure of the same type.

Basically, coodrinates are inserted into the heap using dynamic memory allocation (using the malloc funciton). Using the functions I created, these lists are then strung together using pointers. Using pointers, you can insert another block between two blocks in the list (say if we have to navigate around something) or delete blocks.

Look at my code for details. I've commented it as best I can.

I have seen this type of data structure called either Link Listing or Memory Blocks.

All of my code has been taken almost line-for-line by How to Program C by H.M. Deitel and P.M. Deitel, with a few cosmetic changes.

My problem is that despite including stdio.h and stdlib.h, the compiler claims that the funcion malloc does not exist, giving me the "use of function without prototype" and then an entire slew of errors.

Upon further inspection, I found that the default stdlib.h and stdio.h don't even contain a function prototype for malloc!

I am using MPLAB

Is there something I'm missing? Any help would be Greatly appreciated. My code is attached to this post.

EDIT: After searching a bit I found this. Can I use this in the way I want to?
Attached Files
File Type: h LinkList.h (903 Bytes, 64 views)
File Type: c LInkLIst.c (2.6 KB, 68 views)
__________________

Last edited by slavik262 : 12-02-2008 at 01:11. Reason: Found something!