Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!samsung!uunet!fernwood!dumbcat!marc From: marc@dumbcat.sf.ca.us (Marco S Hyman) Newsgroups: comp.unix.sysv386 Subject: Re: TLI Programming, t_free() problem 386/ix Message-ID: <304@dumbcat.sf.ca.us> Date: 20 May 91 03:59:11 GMT References: <142@icxn.UUCP> Distribution: na Organization: MH Software, Hayward, CA. Lines: 33 In article <142@icxn.UUCP> kjd@icxn.UUCP (Kevin J. Dunlap) writes: > I am having a problem with memory and using AT&T's TLI running on > Interactive 386/ix System V 3.2.2. I have the updates to TCP/IP > installed (SSU.4a). I see your problem. Look at the man page for t_alloc again. I quote: "This function will allocate memory for the specified structure, and will also allocate memory for buffers referenced by the structure." Your t_alloc call if ((unitdata =(struct t_unitdata *)t_alloc(fd,T_UNITDATA,T_ALL))==NULL) { allocates both the t_unitdata structure but also all (T_ALL) fields in the structure. The maxlen field will be initialized for each buffer. Later when you do unitdata->opt.len = 0; unitdata->opt.buf = (char *)NULL; unitdata->udata.len = sizeof(*data); unitdata->udata.buf = (char *)data; You overwrite the pointers that t_alloc built. That memory is lost forever. t_open and t_getinfo will give you the various lengths. If you want to set your own lengths use T_ADDR instead of T_ALL in the t_alloc call. That's all you wanted to allocate in your example. // marc -- // home: marc@dumbcat.sf.ca.us pacbell!dumbcat!marc // work: marc@ascend.com uunet!aria!marc