完成动态内存分配
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#ifndef _DMA_DATA_
|
||||
#define _DMA_DATA_
|
||||
|
||||
struct data{
|
||||
void* pointer;
|
||||
unsigned long size;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef _DMA_INIT_
|
||||
#define _DMA_INIT_
|
||||
|
||||
#include <include/dynamic_memory_allocation/data.h>
|
||||
|
||||
/*创建一个新的数据段*/
|
||||
struct data* new_data();
|
||||
|
||||
/*
|
||||
写入数据到一个数据段
|
||||
_p是要写入的数据段
|
||||
new_data是要写入的数据
|
||||
size是写入的长度,单位为字节
|
||||
函数返回值为0则成功
|
||||
*/
|
||||
int write_data(struct data* _p,void* new_data,int size);
|
||||
|
||||
/*
|
||||
追加数据到一个数据段
|
||||
_p是要写入的数据段
|
||||
add_data是要追加的数据
|
||||
size是追加的长度,单位为字节
|
||||
函数返回值为0则成功
|
||||
*/
|
||||
int add_data(struct data* _p,void* add_data,int size);
|
||||
|
||||
/*
|
||||
从一个数据段读取可读数据
|
||||
_p是要读取的数据段
|
||||
output是输出数据的指针
|
||||
array是读取的偏移量,单位为字节
|
||||
size是读取的长度,单位为字节
|
||||
函数返回值为0则成功
|
||||
*/
|
||||
int read_data(struct data _p,void* output,unsigned int array,unsigned int size);
|
||||
|
||||
/*彻底删除一段数据*/
|
||||
int rm_data(struct data* _p);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef _DMA_
|
||||
#define _DMA_
|
||||
|
||||
#include <include/dynamic_memory_allocation/data.h>
|
||||
#include <include/dynamic_memory_allocation/initialize.h>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <include/dynamic_memory_allocation/main.h>
|
||||
|
||||
#ifndef _SIMPDB_
|
||||
#define _SIMPDB_
|
||||
|
||||
struct database_info{
|
||||
struct data name;
|
||||
struct data path;
|
||||
struct data data_type;
|
||||
struct data data_main;
|
||||
unsigned long size;
|
||||
FILE* pointer;
|
||||
};
|
||||
|
||||
int new_database(struct database_info* db,struct data name,struct data path,struct data data_type);
|
||||
/*创建并加载数据库*/
|
||||
int new_database_nload(struct data name,struct data path,struct data data_type);
|
||||
/*创建但不加载数据库*/
|
||||
int unload_database(struct database_info* db);
|
||||
/*卸载数据库*/
|
||||
#endif
|
||||
Reference in New Issue
Block a user