void make_rand_string(aos_pool_t *p, int len, aos_string_t *data) { char *str = NULL; int i = 0; str = (char *)aos_palloc(p, len + 1); for ( ; i < len; i++) { str[i] = 'a' + rand() % 32; } str[len] = '\0'; aos_str_set(data, str); }
void *oss_create_api_result_content(aos_pool_t *p, size_t size) { void *result_content = aos_palloc(p, size); if (NULL == result_content) { return NULL; } aos_list_init((aos_list_t *)result_content); return result_content; }
aos_buf_t *aos_create_buf(aos_pool_t *p, int size) { aos_buf_t* b; b = aos_palloc(p, sizeof(aos_buf_t) + size); if (b == NULL) { return NULL; } b->pos = (uint8_t *)b + sizeof(aos_buf_t); b->start = b->pos; b->last = b->start; b->end = b->last + size; aos_list_init(&b->node); return b; }
aos_buf_t *aos_buf_pack(aos_pool_t *p, const void *data, int size) { aos_buf_t* b; b = aos_palloc(p, sizeof(aos_buf_t)); if (b == NULL) { return NULL; } b->pos = (uint8_t *)data; b->start = b->pos; b->last = b->start + size; b->end = b->last; aos_list_init(&b->node); return b; }