typedef struct { int cur; int n; char** value; } OrderedStream; OrderedStream* orderedStreamCreate(int n) { OrderedStream* obj=(OrderedStream*)calloc(sizeof(OrderedStream),1); obj->value=(char**)calloc(n+1,sizeof(char*)); obj->n=n+1; obj->cur=1; return obj; } char ** orderedStreamInsert(OrderedStream* obj, int id, char * value, int* retSize) { obj->value[id]=value; int i; for(i=obj->cur; i<obj->n && obj->value[i]; i++); *retSize=i-obj->cur; obj->cur=i; return obj->value+id; } void orderedStreamFree(OrderedStream* obj) { free(obj); }