Giter Site home page Giter Site logo

tiny_mm's Introduction

Discription

小型的内存管理代码,用于32-bit的嵌入式平台。

该模块现在在子函数中合理使用内存有用。进子函数时按顺序A,B,C分配内存,出子函数时按C,B,A的逆序释放内存。 相当于将一大块内存按栈的方式手动进行管理。

已应用于DSP6713处理器信号采集模块中的大块内存管理。

Usage

#define NX      (100)
int x[NX];
float *data1;
int   *data2;

struct st_tiny_mm gb_mm;
tiny_mm_create(&gb_mm, (uint8_t)x, sizeof(int)*NX);
data1 = (float *)tiny_mm_get(&gb_mm, 4*sizeof(float));
if (data1) {
    // process data1 here
}
data2 = (int *)tiny_mm_get(&gb_mm, 3*sizeof(int));
if (data2) {
    // process data2 here
}

// Be careful, must free data2 first than data1 just like a stack.
// So that @tiny_mm module is suite for temporary memory alloc in subfunction.
tiny_mm_put(&gb_mm, (uint32_t **)(&data2), 3*sizeof(float));
tiny_mm_put(&gb_mm, (uint32_t **)(&data1), 4*sizeof(int));

About Me

[email protected]

Copyright (c) MICL, USTB.

tiny_mm's People

Contributors

xiahouzuoxin avatar

Watchers

skyformat99 avatar

Forkers

skyformat99

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.