internals: use ERROR_SUCCESS and ERROR_INSUFICIENT_MEMORY instead of 0/-1