Replaced iterative allocation with a pessimistic upper bound and overloaded wrong standard library prototypes.