[Asterisk-Dev] locate parking lot in res_features.c ?

Luigi Rizzo rizzo at icir.org
Wed Jan 4 11:33:40 MST 2006


The following uncommented code in res_features.c::ast_park_call()
is extremely expensive because it has O(N*M) cost, where N is the
size of the parking lot, and M is the number of parked calls:

        for (i = 0; i < parking_range; i++) {
                x = (i + parking_offset) % parking_range + parking_start;
                for (cur = parkinglot; cur; cur = cur->next)
                        if (cur->parkingnum == x)
                                break;
                if (!cur) /* extension x is free, take it */
                        break;
        }

I _believe_ that what it is trying to do is find the first available parking
extension starting from (parking_start+parking_offset)

Can someone confirm the above behavioural specification ? If so, it can be
replaced by some much cheaper code (which i will post on mantis) that does
only one pass on the parking list so it has cost O(M).

(the question was already on mantis http://bugs.digium.com/view.php?id=6081
but apparently the report has not been processed yet)

	cheers
	luigi



More information about the asterisk-dev mailing list