Newer
Older
Scratch / lockwasher / src / sys / include / lib / Alloc.h
@Christopher W. Olsen Christopher W. Olsen on 25 Oct 2019 882 bytes Scratch
#ifndef __CPP_ALLOC_H
#define __CPP_ALLOC_H

#ifdef __cplusplus

#include <lib/kmalloc.h>

class Alloc 
{
  protected:
    int alloc_size;
    
    uint8_t flags;
    void *  chunks[8];

  public:
    Alloc();
    Alloc(int);
    ~Alloc();
    
    void setSize(int);
    void * allocate();
    void deallocate(void *); 

  private:
    void clear();
	
};

/*
Alloc::Alloc() {
    alloc_size = 0;
    flags = 0x0;
    for (int i = 0; i < 8; i++)
      chunks[i] = (void *) 0x0;
    };

Alloc::Alloc(int size) {
    Alloc();
    alloc_size = size;
    };

Alloc::~Alloc() { clear(); }
void Alloc::setSize(int size) { clear(); alloc_size = size; }

void * Alloc::allocate() {
    if (0 == alloc_size)
      return NULL;
    return kmalloc(alloc_size,-2);
};

void Alloc::deallocate(void * ptr) {
    kfree(ptr);
};

void Alloc::clear() { return; };
*/

    
    
    

#endif

#endif