Se api

Just for preview. Please don't merge it.
What about having a check here, to make sure that *aid is NULL? If you call this twice in row with same "aid", then you will have a memory leak.