Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* mymemory.c
- *
- * provides interface to memory management
- *
- */
- #include <stdio.h>
- #include <unistd.h>
- #include <string.h>
- #include <stdlib.h>
- #include "mymemory.h"
- // our memory
- Byte mymemory [MAXMEM] ;
- Segment_t * segmenttable = NULL;
- int main() {
- initialize();
- }
- void initialize ()
- {
- printf ( "initialize> start\n");
- // set memory to 0
- char mymemory[MAXMEM] = {0};
- // create segment table
- Segment_t *table = NULL;
- printf("-----------------SEGMENT 0---------------------\n");
- printf("-------------------------------------------\n");
- printf("-------------------------------------------\n");
- printf("-------------------------------------------\n");
- printf("-------------------------------------------\n");
- char s[] = "X";
- char *p = &s[0];
- char **pp = &p;
- printf("allocated = FALSE\n");
- printf("start =%p\n", s);
- printf("size =1024\n");
- printf("------------------------------------------\n");
- printf("-------------------------------------------\n");
- printf("-------------------------------------------\n");
- printf("-----------------TABLE---------------------\n");
- // contains one segment description that declares the whole memory
- // as one free segment
- //
- // create a single segment descriptor
- // initialise the segment
- printf ( "initialize> end\n");
- }
- //void myfree ( void * ptr )
- //{
- //}
- void * mymalloc ( size_t size )
- {
- printf ( "mymalloc> start\n");
- // implement the mymalloc functionality
- }
- //void myfree ( void * ptr )
- //{
- // printf ( "myfree> start\n");
- //
- //}
- void mydefrag ( void ** ptrlist)
- {
- printf ( "mydefrag> start\n");
- }
- // helper functions for management segmentation table
- Segment_t * findFree ( Segment_t * list, size_t size )
- {
- printf ( "findFree> start\n");
- }
- void insertAfter ( Segment_t * oldSegment, Segment_t * newSegment )
- {
- }
- Segment_t * findSegment ( Segment_t * list, void * ptr )
- {
- }
- int isPrintable ( int c )
- {
- if ( c >= 0x20 && c <= 0x7e ) return c ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement