30 lines
678 B
C
30 lines
678 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define FLEXABLE_LEN 0
|
|
#define PAGE_SIZE 8192
|
|
|
|
typedef struct {
|
|
int low;
|
|
int high;
|
|
int capacity;
|
|
char data[FLEXABLE_LEN];
|
|
} SimplePage;
|
|
|
|
int main(int argc, char **argv) {
|
|
SimplePage *page = (SimplePage *) malloc(PAGE_SIZE);
|
|
memset(page, 0, PAGE_SIZE);
|
|
int base_size = sizeof(SimplePage);
|
|
page->capacity = PAGE_SIZE - base_size;
|
|
page->low = 0;
|
|
page->high = page->capacity;
|
|
|
|
char *s = "测试数据";
|
|
int s_len = strlen(s);
|
|
int tmp_pos = page->high - s_len;
|
|
char *start_cpy = &(page->data[tmp_pos]);
|
|
memcpy(start_cpy, s, s_len);
|
|
free(page);
|
|
return 0;
|
|
} |