4.0

4.0 | 1 rating Rate this file 122 downloads (last 30 days) File Size: 6.52 KB File ID: #25179

Pointers Toolbox

by Ben Petschel

 

31 Aug 2009

Code covered by BSD License  

basic functions to work with pointer variables and dynamic data types

Download Now | Watch this File

File Information
Description

This toolbox implements pointer variables and can be used to implement dynamic data structures such as linked lists.

In this implementation, virtual memory is simply a large cell array and the pointers are integers that index into it. The core program keeps track of which slots are used and which are free and leaves it up to the user to ensure that all allocated slots are being used and that all pointers are used correctly.

Some advantages of this approach are that the virtual memory is distinct from the rest of the workspace, and any object can be assigned to a given memory slot.

The toolbox is intended mainly for pedagogical purposes, and provides a safe environment to learn about linked lists, dynamic data structures, wild pointers, dangling pointers, memory leaks, seg faults, etc - without having to worry about things like low-level memory allocation and type matching.

The demo file shows how to use the basic routines MALLOC, MREAD, MWRITE, MFREE, MWIPE, and how to implement a stack as a linked list.

Let me know if you find this useful. Enjoy!

MATLAB release MATLAB 7.8 (R2009a)
Zip File Content  
Published M Files Pointers Toolbox
Other Files demo_ptr.m,
license.txt,
malloc.m,
mfree.m,
mmgr.m,
mread.m,
mwipe.m,
mwrite.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
01 Sep 2009 Philip  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
pointer Ben Petschel 31 Aug 2009 13:42:53
pointer object Ben Petschel 31 Aug 2009 13:42:53
dynamic data type Ben Petschel 31 Aug 2009 13:42:53
virtual memory Ben Petschel 31 Aug 2009 13:42:53
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com