Add allocation checks for buffer usage