Don't know if this is a big issue, but this API fills some amount of the array with the information, leaving the rest uninitialized, and does not return how many elements in the array were actually set. Of course if the caller can check ctx->num_listening_sockets before and/or after the call to overcome this issue, but if this ctx is considered opaque from this API functions point of view then it is laborous to check how many port numbers were initialized. Of course you can memset() the array to zeros or -1s before the call, but maybe for example returning the amount actually filled might make sense. Not sure though.