1 #include <stdio.h> 2 3 #include "blobmsg.h" 4 5 /* chunks of 64KB to be added to blob-buffer */ 6 #define BUFF_SIZE 0x10000 7 /* exceed maximum blob buff-length */ 8 #define BUFF_CHUNKS (((BLOB_ATTR_LEN_MASK + 1) / BUFF_SIZE) + 1) 9 10 int main(int argc, char **argv) 11 { 12 int i; 13 static struct blob_buf buf; 14 blobmsg_buf_init(&buf); 15 int prev_len = buf.buflen; 16 17 for (i = 0; i < BUFF_CHUNKS; i++) { 18 struct blob_attr *attr = blob_new(&buf, 0, BUFF_SIZE); 19 if (!attr) { 20 fprintf(stderr, "SUCCESS: failed to allocate attribute\n"); 21 break; 22 } 23 if (prev_len < buf.buflen) { 24 prev_len = buf.buflen; 25 continue; 26 } 27 fprintf(stderr, "ERROR: buffer length did not increase\n"); 28 return -1; 29 } 30 return 0; 31 } 32
This page was automatically generated by LXR 0.3.1. • OpenWrt