a few C helpers