Analyzing memory ownership patterns in C libraries