01. kmalloc 宣告記憶體

01. kmalloc 宣告記憶體

    宣告記憶體的使用方法

    /* Buffer to store data */
    char *memory_buffer;
    int memory_init(void) {
     /* Allocating memory for the buffer */
      memory_buffer = kmalloc(1, GFP_KERNEL);
      if (!memory_buffer) 
        result = -ENOMEM;
      }else{
     result = 0;
    }
    return result;
    }