[DDMD] [refactor] Move some functions in glue.c into free functions