quindi

int n=max(getlength2(num1),getlength2(num2));
int *res=(int *)malloc(getlength2(num1)+getlength2(num2))*sizeof (int));