I don't think there's a better approach, but you're making assumptions about what pj_str does to its parameters - by declaring pj_str without a const, it's saying that it can modify your parameter (whether or not the result is a const).  It might not (and probably doesn't) modify it, but please double-check.