In short: No.
To free allocated memory you need a reference to it.
If you could change your conversion API, a possible work around could be to use an externally provided buffer:
char * itoa(char * t, int i)
{
sprintf(t,"%d",a);
return t;
}
Call itoa()
this way then:
{
char buffer [16];
mvwprintw(my_menu_win,i+1,2,itoa(buffer, i));
}
Alternatively (C99 only) one could do the call to itoa()
this way:
mvwprintw(my_menu_win,i+1,2,itoa((char[16]){0}, i));
So to clean up this a macro helps:
#define ITOA_0(i) itoa((char[16]){0}, i) /* init array with 0s */
#define ITOA(i) itoa((char[16]){}, i) /* do not init array with 0s -> faster, but none ISO */
...
mvwprintw(my_menu_win,i+1,2,ITOA(i));