Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. /* mymemory.c
  2. *
  3. * provides interface to memory management
  4. *
  5. */
  6. #include <stdio.h>
  7. #include <unistd.h>
  8. #include <string.h>
  9. #include <stdlib.h>
  10. #include "mymemory.h"
  11.  
  12.  
  13. // our memory
  14. Byte mymemory [MAXMEM] ;
  15. Segment_t * segmenttable = NULL;
  16.  
  17.  
  18. int main() {
  19. initialize();
  20.  
  21. }
  22.  
  23.  
  24.  
  25.  
  26. void initialize ()
  27. {
  28. printf ( "initialize> start\n");
  29. // set memory to 0
  30. char mymemory[MAXMEM] = {0};
  31.  
  32.  
  33. // create segment table
  34. Segment_t *table = NULL;
  35. printf("-----------------SEGMENT 0---------------------\n");
  36. printf("-------------------------------------------\n");
  37. printf("-------------------------------------------\n");
  38. printf("-------------------------------------------\n");
  39. printf("-------------------------------------------\n");
  40. char s[] = "X";
  41. char *p = &s[0];
  42. char **pp = &p;
  43. printf("allocated = FALSE\n");
  44. printf("start =%p\n", s);
  45. printf("size =1024\n");
  46. printf("------------------------------------------\n");
  47. printf("-------------------------------------------\n");
  48. printf("-------------------------------------------\n");
  49. printf("-----------------TABLE---------------------\n");
  50. // contains one segment description that declares the whole memory
  51. // as one free segment
  52. //
  53. // create a single segment descriptor
  54.  
  55. // initialise the segment
  56.  
  57. printf ( "initialize> end\n");
  58. }
  59.  
  60. //void myfree ( void * ptr )
  61. //{
  62.  
  63. //}
  64.  
  65. void * mymalloc ( size_t size )
  66. {
  67. printf ( "mymalloc> start\n");
  68.  
  69. // implement the mymalloc functionality
  70. }
  71.  
  72. //void myfree ( void * ptr )
  73. //{
  74. // printf ( "myfree> start\n");
  75. //
  76. //}
  77.  
  78. void mydefrag ( void ** ptrlist)
  79. {
  80. printf ( "mydefrag> start\n");
  81.  
  82. }
  83.  
  84.  
  85. // helper functions for management segmentation table
  86. Segment_t * findFree ( Segment_t * list, size_t size )
  87. {
  88. printf ( "findFree> start\n");
  89.  
  90.  
  91. }
  92.  
  93. void insertAfter ( Segment_t * oldSegment, Segment_t * newSegment )
  94. {
  95. }
  96.  
  97. Segment_t * findSegment ( Segment_t * list, void * ptr )
  98. {
  99. }
  100.  
  101. int isPrintable ( int c )
  102. {
  103. if ( c >= 0x20 && c <= 0x7e ) return c ;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement