[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Proper patching source code with HOST_NAME_MAX usage
I developed a patch over the weekend to upgrade net/rdesktop to the
current version 1.9.0. The version currently in pkgsrc has an unpleasant
The patch works, but I would like to clarify one detail before
submitting. In the file xwin.c a variable hostname is defined in the
method set_wm_client_machine in the following way:
char hostname [HOST_NAME_MAX];
The macro HOST_NAME_MAX does not exist in NetBSD. Instead, I read
sysconf (_SC_HOST_NAME_MAX) should be used. My C course was two decades
ago, but if I remember correctly I can't just use it instead of
So my question is: what is the best way to deal with it?
a) Use of MAXHOSTNAMELEN from sys/param.h
b) Convert the variable into a pointer variable and use allocation of
the appropriate length at runtime? Disadvantage: memory would actually
have to be released again, i.e. more intervention in the original source
code than I actually want to do ..
c) is there anything more elegant that I don't know about yet?
I have essentially oriented myself towards  and appreciate comments.
Petermann IT / M. Petermann <mp%petermann-it.de@localhost> | www.petermann-it.de
Wildparkring 13, 01458 Ottendorf-Okrilla | Tel.: +49 (0)35205 597 991
Main Index |
Thread Index |