Advertisement
techno-

ListaMmap.c

Nov 12th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. #define maxMmap 4096
  6.  
  7. typedef struct{
  8.     int *dir;
  9.     int Bytes;
  10.     int month;
  11.     int dia;
  12.     int hora;
  13.     int min;
  14.     char nombre[20];
  15.     int filedescriptor;
  16. }mmapTipo;
  17.  
  18. mmapTipo *HistMmap[maxMmap];
  19.  
  20. int nmmap = 0; //Numero de elementos en el array
  21.  
  22. void histMmapInsert(int *dir, int Bytes, int month, int dia, int hora, int min, char *nombre, int filedescriptor){
  23.    
  24.     if(nmmap == maxMmap){
  25.         printf("Espacio del historial agotado");
  26.         return;
  27.     }
  28.     else{
  29.         nmmap++;
  30.         HistMmap[nmmap-1]=malloc(sizeof(mmapTipo));
  31.         HistMmap[nmmap-1]->dir=dir;
  32.         HistMmap[nmmap-1]->Bytes=Bytes;
  33.         HistMmap[nmmap-1]->month=month;
  34.         HistMmap[nmmap-1]->dia=dia;
  35.         HistMmap[nmmap-1]->hora=hora;
  36.         HistMmap[nmmap-1]->min=min;
  37.         strcpy(HistMmap[nmmap-1]->nombre,nombre);
  38.         HistMmap[nmmap-1]->filedescriptor=filedescriptor;
  39.     }
  40. }
  41.  
  42. mmapTipo *histMmapElemento(int n){
  43.     return HistMmap[n];
  44. }
  45.  
  46. int histMmapNumElementos(){
  47.     return nmmap;
  48. }
  49.  
  50. void histMmapBorrar(){
  51.     int i;
  52.     for(i=0; i <= nmmap; i++){
  53.         free(HistMmap[i]);
  54.     }
  55.     nmmap = 0;
  56. }
  57.  
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement