Commit 7f645087b9d4a58413813dd551ef5a6e190d1146

Authored by perry.werneck@gmail.com
1 parent 327bd804

Debuggando gerenciamento de memória a procura de segfaults aleatórios

XtGlue.c
... ... @@ -38,7 +38,7 @@
38 38  
39 39 #include "globals.h"
40 40 #include "api.h"
41   -#include <malloc.h>
  41 +// #include <malloc.h>
42 42  
43 43 #if defined(_WIN32)
44 44 #include "appres.h"
... ... @@ -179,8 +179,7 @@ static void * DefaultAddTimeOut(unsigned long interval_ms, H3270 *session, void
179 179  
180 180 Trace("%s session=%p proc=%p",__FUNCTION__,session,proc);
181 181  
182   - t_new = (timeout_t *)Malloc(sizeof(timeout_t));
183   - memset(t_new,0,sizeof(timeout_t));
  182 + t_new = (timeout_t *) lib3270_malloc(sizeof(timeout_t));
184 183  
185 184 t_new->proc = proc;
186 185 t_new->session = session;
... ... @@ -244,7 +243,7 @@ static void DefaultRemoveTimeOut(void * timer)
244 243 prev->next = t->next;
245 244 else
246 245 timeouts = t->next;
247   - Free(t);
  246 + lib3270_free(t);
248 247 return;
249 248 }
250 249 prev = t;
... ... @@ -268,8 +267,7 @@ static void * DefaultAddInput(int source, H3270 *session, void (*fn)(H3270 *sess
268 267  
269 268 Trace("%s session=%p proc=%p",__FUNCTION__,session,fn);
270 269  
271   - ip = (input_t *) Malloc(sizeof(input_t));
272   - memset(ip,0,sizeof(input_t));
  270 + ip = (input_t *) lib3270_malloc(sizeof(input_t));
273 271  
274 272 ip->source = source;
275 273 ip->condition = InputReadMask;
... ... @@ -293,8 +291,7 @@ static void * DefaultAddExcept(int source, H3270 *session, void (*fn)(H3270 *ses
293 291  
294 292 Trace("%s session=%p proc=%p",__FUNCTION__,session,fn);
295 293  
296   - ip = (input_t *)Malloc(sizeof(input_t));
297   - memset(ip,0,sizeof(input_t));
  294 + ip = (input_t *) lib3270_malloc(sizeof(input_t));
298 295  
299 296 ip->source = source;
300 297 ip->condition = InputExceptMask;
... ... @@ -317,7 +314,7 @@ static void * DefaultAddOutput(int source, H3270 *session, void (*fn)(H3270 *ses
317 314  
318 315 Trace("%s session=%p proc=%p",__FUNCTION__,session,fn);
319 316  
320   - ip = (input_t *)Malloc(sizeof(input_t));
  317 + ip = (input_t *)lib3270_malloc(sizeof(input_t));
321 318 memset(ip,0,sizeof(input_t));
322 319  
323 320 ip->source = source;
... ... @@ -356,7 +353,7 @@ static void DefaultRemoveInput(void *id)
356 353 else
357 354 inputs = ip->next;
358 355  
359   - Free(ip);
  356 + lib3270_free(ip);
360 357 inputs_changed = True;
361 358 }
362 359  
... ... @@ -545,7 +542,7 @@ static int DefaultProcessEvents(int block)
545 542 t->in_play = True;
546 543 (*t->proc)(t->session);
547 544 processed_any = True;
548   - Free(t);
  545 + lib3270_free(t);
549 546 } else
550 547 break;
551 548 }
... ...
actions.c
... ... @@ -163,10 +163,10 @@ action_internal(XtActionProc action, enum iaction cause, const char *parm1,
163 163 // Free the parm copies.
164 164 switch (count) {
165 165 case 2:
166   - Free(parms[1]);
  166 + lib3270_free(parms[1]);
167 167 // fall through...
168 168 case 1:
169   - Free(parms[0]);
  169 + lib3270_free(parms[0]);
170 170 break;
171 171 default:
172 172 break;
... ...
ansi.c
... ... @@ -600,7 +600,7 @@ ansi_reset(int ig1 unused, int ig2 unused)
600 600 saved_altbuffer = False;
601 601 scroll_top = 1;
602 602 scroll_bottom = h3270.rows;
603   - Replace(tabs, (unsigned char *)Malloc((h3270.cols+7)/8));
  603 + Replace(tabs, (unsigned char *)lib3270_malloc((h3270.cols+7)/8));
604 604 for (i = 0; i < (h3270.cols+7)/8; i++)
605 605 tabs[i] = 0x01;
606 606 held_wrap = False;
... ...
charset.c
... ... @@ -227,7 +227,7 @@ enum cs_result charset_init(H3270 *session, const char *csname)
227 227 // Grab the non-Euro definition.
228 228 basename = xs_buffer("%.*s", (int) (strlen(csname) - ES_SIZE), csname);
229 229 cs = get_charset_def(basename);
230   - Free(basename);
  230 + lib3270_free(basename);
231 231 }
232 232 */
233 233 if (!ccs)
... ... @@ -251,8 +251,8 @@ enum cs_result charset_init(H3270 *session, const char *csname)
251 251 rc = resource_charset(csname, ccs, cftcs);
252 252  
253 253 /* Free them. */
254   - Free(ccs);
255   - Free(cftcs);
  254 + lib3270_free(ccs);
  255 + lib3270_free(cftcs);
256 256  
257 257 #if defined(DEBUG_CHARSET) /*[*/
258 258 if (rc == CS_OKAY)
... ... @@ -340,7 +340,7 @@ static void set_cgcsgids(const char *spec)
340 340 }
341 341 n_ids++;
342 342 }
343   - Free(spec_copy);
  343 + lib3270_free(spec_copy);
344 344 if (n_ids > 0)
345 345 return;
346 346 }
... ... @@ -681,7 +681,7 @@ static enum cs_result remap_chars(const char *csname, char *spec, remap_scope sc
681 681 remap_one(ebc, iso, scope, one_way);
682 682 }
683 683 }
684   - Free(spec);
  684 + lib3270_free(spec);
685 685 return rc;
686 686 }
687 687  
... ...
ft.c
... ... @@ -340,8 +340,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state);
340 340 ft_last_cr = False;
341 341 ft_is_cut = False;
342 342  
343   - ftHandle = malloc(sizeof(H3270FT));
344   - memset(ftHandle,0,sizeof(H3270FT));
  343 + ftHandle = lib3270_malloc(sizeof(H3270FT));
345 344  
346 345 ftHandle->sz = sizeof(H3270FT);
347 346 ftHandle->host = session;
... ...
ft_cut.c
... ... @@ -36,7 +36,7 @@
36 36 */
37 37  
38 38 #include <errno.h>
39   -#include <malloc.h>
  39 +// #include <malloc.h>
40 40  
41 41 #include "globals.h"
42 42  
... ... @@ -340,7 +340,7 @@ cut_control_code(void)
340 340 }
341 341 else
342 342 {
343   - bp = buf = Malloc(81);
  343 + bp = buf = lib3270_malloc(81);
344 344  
345 345 for (i = 0; i < 80; i++)
346 346 *bp++ = ebc2asc[h3270.ea_buf[O_CC_MESSAGE + i].cc];
... ... @@ -360,7 +360,7 @@ cut_control_code(void)
360 360 strcpy(buf, N_( "Transfer cancelled by host" ) );
361 361 }
362 362 ft_complete(NULL,buf);
363   - Free(buf);
  363 + lib3270_free(buf);
364 364 break;
365 365  
366 366 default:
... ... @@ -528,7 +528,7 @@ static void cut_abort(unsigned short reason, const char *fmt, ...)
528 528 va_list args;
529 529  
530 530 if(saved_errmsg)
531   - free(saved_errmsg);
  531 + lib3270_free(saved_errmsg);
532 532  
533 533 /* Save the error message. */
534 534 va_start(args, fmt);
... ...
ft_dft.c
... ... @@ -55,7 +55,7 @@
55 55 #include "utilc.h"
56 56  
57 57 #include <errno.h>
58   -#include <malloc.h>
  58 +// #include <malloc.h>
59 59  
60 60 extern unsigned char aid;
61 61  
... ... @@ -243,7 +243,7 @@ dft_data_insert(struct data_buffer *data_bufr)
243 243 unsigned char *dollarp;
244 244  
245 245 /* Get storage to copy the message. */
246   - msgp = (unsigned char *)Malloc(my_length + 1);
  246 + msgp = (unsigned char *)lib3270_malloc(my_length + 1);
247 247  
248 248 /* Copy the message. */
249 249 memcpy(msgp, data_bufr->data, my_length);
... ... @@ -257,15 +257,15 @@ dft_data_insert(struct data_buffer *data_bufr)
257 257  
258 258 /* If transfer completed ok, use our msg. */
259 259 if (memcmp(msgp, END_TRANSFER, strlen(END_TRANSFER)) == 0) {
260   - Free(msgp);
  260 + lib3270_free(msgp);
261 261 ft_complete(NULL,NULL);
262 262 } else if (lib3270_get_ft_state(&h3270) == FT_ABORT_SENT && abort_string != CN) {
263   - Free(msgp);
  263 + lib3270_free(msgp);
264 264 ft_complete(NULL,abort_string);
265 265 Replace(abort_string, CN);
266 266 } else {
267 267 ft_complete(NULL,(char *)msgp);
268   - Free(msgp);
  268 + lib3270_free(msgp);
269 269 }
270 270 } else if (my_length > 0) {
271 271 /* Write the data out to the file. */
... ... @@ -459,7 +459,7 @@ dft_get_request(void)
459 459 dft_savebuf_len = obptr - obuf;
460 460 if (dft_savebuf_len > dft_savebuf_max) {
461 461 dft_savebuf_max = dft_savebuf_len;
462   - Replace(dft_savebuf, (unsigned char *)Malloc(dft_savebuf_max));
  462 + Replace(dft_savebuf, (unsigned char *)lib3270_malloc(dft_savebuf_max));
463 463 }
464 464 (void) memcpy(dft_savebuf, obuf, dft_savebuf_len);
465 465 aid = AID_SF;
... ... @@ -494,7 +494,7 @@ static void dft_abort(unsigned short code, const char *fmt, ...)
494 494 va_list args;
495 495  
496 496 if(abort_string)
497   - free(abort_string);
  497 + lib3270_free(abort_string);
498 498  
499 499 va_start(args, fmt);
500 500 abort_string = xs_vsprintf(fmt, args);
... ...
globals.h
... ... @@ -318,7 +318,7 @@ LIB3270_INTERNAL struct trans_list *trans_list;
318 318  
319 319 #define CN ((char *) NULL)
320 320 #define PN ((XtPointer) NULL)
321   -#define Replace(var, value) { Free(var); var = (value); }
  321 +#define Replace(var, value) { lib3270_free(var); var = (value); }
322 322  
323 323 /* Configuration change masks. */
324 324 #define NO_CHANGE 0x0000 /* no change */
... ...
glue.c
... ... @@ -563,7 +563,7 @@ parse_xrm(const char *arg, const char *where)
563 563 type = resources[i].type;
564 564 #if defined(C3270) /*[*/
565 565 if (address == NULL) {
566   - add_buf = Malloc(strlen(s) + 1);
  566 + add_buf = lib3270_malloc(strlen(s) + 1);
567 567 address = add_buf;
568 568 }
569 569 #endif /*]*/
... ... @@ -619,7 +619,7 @@ parse_xrm(const char *arg, const char *where)
619 619 }
620 620 break;
621 621 case XRM_STRING:
622   - t = Malloc(strlen(s) + 1);
  622 + t = lib3270_malloc(strlen(s) + 1);
623 623 *(char **)address = t;
624 624 if (*s == '"') {
625 625 Boolean quoted = False;
... ... @@ -675,7 +675,7 @@ parse_xrm(const char *arg, const char *where)
675 675 if (arbitrary) {
676 676 char *rsname;
677 677  
678   - rsname = Malloc(rnlen + 1);
  678 + rsname = lib3270_malloc(rnlen + 1);
679 679 (void) strncpy(rsname, arg + match_len, rnlen);
680 680 rsname[rnlen] = '\0';
681 681 add_resource(rsname, hide);
... ... @@ -702,7 +702,7 @@ read_resource_file(const char *filename, Boolean fatal)
702 702 }
703 703  
704 704 /* Merge in what's in the file into the resource database. */
705   - where = Malloc(strlen(filename) + 64);
  705 + where = lib3270_malloc(strlen(filename) + 64);
706 706  
707 707 ilen = 0;
708 708 while (fgets(buf + ilen, sizeof(buf) - ilen, f) != CN || ilen) {
... ... @@ -783,7 +783,7 @@ read_resource_file(const char *filename, Boolean fatal)
783 783 /* Get ready for the next iteration. */
784 784 ilen = 0;
785 785 }
786   - Free(where);
  786 + lib3270_free(where);
787 787 return 0;
788 788 }
789 789  
... ...
host.c
... ... @@ -52,7 +52,7 @@
52 52 #include "xioc.h"
53 53  
54 54 #include <errno.h>
55   -#include <malloc.h>
  55 +// #include <malloc.h>
56 56  
57 57 #define RECONNECT_MS 2000 /* 2 sec before reconnecting to host */
58 58 #define RECONNECT_ERR_MS 5000 /* 5 sec before reconnecting to host */
... ... @@ -124,10 +124,10 @@ hostfile_init(void)
124 124 ResHostsFile);
125 125 continue;
126 126 }
127   - h = (struct host *)Malloc(sizeof(*h));
  127 + h = (struct host *)lib3270_malloc(sizeof(*h));
128 128 if (!split_hier(NewString(name), &h->name,
129 129 &h->parents)) {
130   - Free(h);
  130 + lib3270_free(h);
131 131 continue;
132 132 }
133 133 h->hostname = NewString(hostname);
... ... @@ -160,7 +160,7 @@ hostfile_init(void)
160 160 popup_an_errno(errno, "Cannot open " ResHostsFile " '%s'",
161 161 appres.hostsfile);
162 162 }
163   - Free(hostfile_name);
  163 + lib3270_free(hostfile_name);
164 164  
165 165 // #if defined(X3270_DISPLAY)
166 166 // save_recent(CN);
... ... @@ -465,7 +465,7 @@ split_host(H3270 *hSession, char *s, char *ansi, char *std_ds, char *passthru,
465 465 goto split_success;
466 466  
467 467 split_fail:
468   - Free(r);
  468 + lib3270_free(r);
469 469 r = CN;
470 470  
471 471 split_success:
... ... @@ -803,7 +803,7 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n)
803 803 trace("new hostname is \"%s\"",new_hostname);
804 804  
805 805 if(h->full_current_host)
806   - free(h->full_current_host);
  806 + lib3270_free(h->full_current_host);
807 807  
808 808 h->full_current_host = new_hostname;
809 809  
... ...
init.c
... ... @@ -61,7 +61,7 @@ void lib3270_session_free(H3270 *h)
61 61 while(h->st_callbacks[f])
62 62 {
63 63 struct lib3270_state_callback *next = h->st_callbacks[f]->next;
64   - Free(h->st_callbacks[f]);
  64 + lib3270_free(h->st_callbacks[f]);
65 65 h->st_callbacks[f] = next;
66 66 }
67 67 }
... ...
kybd.c
... ... @@ -222,9 +222,7 @@ static int enq_chk(void)
222 222 if(enq_chk())
223 223 return;
224 224  
225   - ta = (struct ta *) Malloc(sizeof(*ta));
226   - memset(ta,0,sizeof(struct ta));
227   -
  225 + ta = (struct ta *) lib3270_malloc(sizeof(*ta));
228 226 ta->next = (struct ta *) NULL;
229 227 ta->type = TA_TYPE_KEY_AID;
230 228 ta->aid_code = aid_code;
... ... @@ -257,8 +255,7 @@ static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char
257 255  
258 256 CHECK_SESSION_HANDLE(hSession);
259 257  
260   - ta = (struct ta *) Malloc(sizeof(*ta));
261   - memset(ta,0,sizeof(struct ta));
  258 + ta = (struct ta *) lib3270_malloc(sizeof(*ta));
262 259 ta->session = hSession;
263 260 ta->next = (struct ta *) NULL;
264 261 ta->type = TA_TYPE_DEFAULT;
... ... @@ -277,7 +274,7 @@ static void enq_ta(H3270 *hSession, void (*fn)(H3270 *, const char *, const char
277 274 else
278 275 {
279 276 ta_head = ta;
280   - status_typeahead(&h3270,True);
  277 + status_typeahead(hSession,True);
281 278 }
282 279 ta_tail = ta;
283 280  
... ... @@ -304,9 +301,8 @@ Boolean run_ta(void)
304 301 {
305 302 case TA_TYPE_DEFAULT:
306 303 ta->fn(ta->session,ta->parm[0],ta->parm[1]);
307   - Free(ta->parm[0]);
308   - Free(ta->parm[1]);
309   - Free(ta);
  304 + lib3270_free(ta->parm[0]);
  305 + lib3270_free(ta->parm[1]);
310 306 break;
311 307  
312 308 case TA_TYPE_KEY_AID:
... ... @@ -319,6 +315,8 @@ Boolean run_ta(void)
319 315  
320 316 }
321 317  
  318 + lib3270_free(ta);
  319 +
322 320 return True;
323 321 }
324 322  
... ... @@ -334,10 +332,10 @@ flush_ta(void)
334 332  
335 333 for (ta = ta_head; ta != (struct ta *) NULL; ta = next)
336 334 {
337   - Free(ta->parm[0]);
338   - Free(ta->parm[1]);
  335 + lib3270_free(ta->parm[0]);
  336 + lib3270_free(ta->parm[1]);
339 337 next = ta->next;
340   - Free(ta);
  338 + lib3270_free(ta);
341 339 any = True;
342 340 }
343 341 ta_head = ta_tail = (struct ta *) NULL;
... ... @@ -3466,7 +3464,7 @@ void
3466 3464 clear_xks(void)
3467 3465 {
3468 3466 if (nxk) {
3469   - Free(xk);
  3467 + lib3270_free(xk);
3470 3468 xk = (struct xks *)NULL;
3471 3469 nxk = 0;
3472 3470 }
... ...
localdefs.h
... ... @@ -68,8 +68,8 @@ typedef struct _XtActionsRec{
68 68 // void * Calloc(size_t, size_t);
69 69 // void * Realloc(void *, size_t);
70 70  
71   -#define Malloc(x) lib3270_malloc(x)
72   -#define Free(x) lib3270_free(x)
  71 +// #define Malloc(x) lib3270_malloc(x)
  72 +// #define Free(x) lib3270_free(x)
73 73 #define Calloc(e,n) lib3270_calloc(e,n,NULL)
74 74 #define Realloc(x,n) lib3270_realloc(x,n)
75 75  
... ...
macros.c
... ... @@ -33,7 +33,7 @@
33 33 #include <errno.h>
34 34 #include <string.h>
35 35 #include <stdio.h>
36   - #include <malloc.h>
  36 +// #include <malloc.h>
37 37 #include <lib3270.h>
38 38 #include <lib3270/macros.h>
39 39 #include <stdlib.h>
... ... @@ -113,7 +113,7 @@
113 113 case 1: // Get entire screen
114 114 lib3270_get_screen_size(hSession,&rows,&cols);
115 115 qtd = (rows*(cols+1)+1);
116   - buffer = malloc(qtd+2);
  116 + buffer = lib3270_malloc(qtd+2);
117 117  
118 118 memset(buffer,0,qtd+1);
119 119 start = qtd = 0;
... ... @@ -165,7 +165,7 @@
165 165 return NULL;
166 166 }
167 167  
168   - buffer = malloc(qtd+1);
  168 + buffer = lib3270_malloc(qtd+1);
169 169 screen_read(buffer, start, qtd);
170 170  
171 171 */
... ... @@ -231,7 +231,7 @@
231 231 host = "-";
232 232  
233 233 sz = strlen(luname)+strlen(state)+strlen(host)+4;
234   - rsp = malloc(sz+1);
  234 + rsp = lib3270_malloc(sz+1);
235 235 snprintf(rsp,sz,"%s %s %s",state,luname,host);
236 236 return rsp;
237 237 }
... ...
paste.c
... ... @@ -45,7 +45,7 @@
45 45 #endif
46 46  
47 47 #include <fcntl.h>
48   -#include <malloc.h>
  48 +// #include <malloc.h>
49 49  
50 50 #include "3270ds.h"
51 51 #include "appres.h"
... ... @@ -254,7 +254,7 @@ LIB3270_EXPORT int lib3270_paste(H3270 *h, const unsigned char *str)
254 254  
255 255 if(h->paste_buffer)
256 256 {
257   - free(h->paste_buffer);
  257 + lib3270_free(h->paste_buffer);
258 258 h->paste_buffer = NULL;
259 259 }
260 260  
... ... @@ -296,6 +296,6 @@ LIB3270_ACTION(pastenext)
296 296  
297 297 rc = lib3270_paste(hSession,(unsigned char *) ptr);
298 298  
299   - free(ptr);
  299 + lib3270_free(ptr);
300 300 return rc;
301 301 }
... ...
proxy.c
... ... @@ -56,7 +56,7 @@
56 56  
57 57 #else
58 58  
59   - #include <malloc.h>
  59 +// #include <malloc.h>
60 60 #include <sys/socket.h>
61 61 #include <sys/ioctl.h>
62 62 #include <netinet/in.h>
... ... @@ -306,7 +306,7 @@ parse_host_port(char *s, char **phost, char **pport)
306 306 *pport = NewString(colon + 1);
307 307  
308 308 /* Copy out the hostname. */
309   - *phost = Malloc(hlen + 1);
  309 + *phost = lib3270_malloc(hlen + 1);
310 310 strncpy(*phost, hstart, hlen);
311 311 (*phost)[hlen] = '\0';
312 312 return 0;
... ... @@ -347,7 +347,7 @@ proxy_passthru(int fd, char *host, unsigned short port)
347 347 {
348 348 char *buf;
349 349  
350   - buf = Malloc(strlen(host) + 32);
  350 + buf = lib3270_malloc(strlen(host) + 32);
351 351 (void) sprintf(buf, "%s %u\r\n", host, port);
352 352  
353 353 #if defined(X3270_TRACE) /*[*/
... ... @@ -357,10 +357,10 @@ proxy_passthru(int fd, char *host, unsigned short port)
357 357  
358 358 if (send(fd, buf, strlen(buf), 0) < 0) {
359 359 popup_a_sockerr(NULL,"Passthru Proxy: send error");
360   - Free(buf);
  360 + lib3270_free(buf);
361 361 return -1;
362 362 }
363   - Free(buf);
  363 + lib3270_free(buf);
364 364  
365 365 return 0;
366 366 }
... ... @@ -377,7 +377,7 @@ proxy_http(int fd, char *host, unsigned short port)
377 377 char *space;
378 378  
379 379 /* Send the CONNECT request. */
380   - buf = Malloc(64 + strlen(host));
  380 + buf = lib3270_malloc(64 + strlen(host));
381 381 colon = strchr(host, ':');
382 382 sprintf(buf, "CONNECT %s%s%s:%u HTTP/1.1\r\n",
383 383 (colon? "[": ""),
... ... @@ -392,7 +392,7 @@ proxy_http(int fd, char *host, unsigned short port)
392 392  
393 393 if (send(fd, buf, strlen(buf), 0) < 0) {
394 394 popup_a_sockerr(NULL,"HTTP Proxy: send error");
395   - Free(buf);
  395 + lib3270_free(buf);
396 396 return -1;
397 397 }
398 398  
... ... @@ -409,7 +409,7 @@ proxy_http(int fd, char *host, unsigned short port)
409 409  
410 410 if (send(fd, buf, strlen(buf), 0) < 0) {
411 411 popup_a_sockerr(NULL,"HTTP Proxy: send error");
412   - Free(buf);
  412 + lib3270_free(buf);
413 413 return -1;
414 414 }
415 415  
... ... @@ -421,10 +421,10 @@ proxy_http(int fd, char *host, unsigned short port)
421 421  
422 422 if (send(fd, buf, strlen(buf), 0) < 0) {
423 423 popup_a_sockerr(NULL,"HTTP Proxy: send error");
424   - Free(buf);
  424 + lib3270_free(buf);
425 425 return -1;
426 426 }
427   - Free(buf);
  427 + lib3270_free(buf);
428 428  
429 429 /*
430 430 * Process the reply.
... ... @@ -498,7 +498,7 @@ proxy_telnet(int fd, char *host, unsigned short port)
498 498 {
499 499 char *buf;
500 500  
501   - buf = Malloc(strlen(host) + 32);
  501 + buf = lib3270_malloc(strlen(host) + 32);
502 502 (void) sprintf(buf, "connect %s %u\r\n", host, port);
503 503  
504 504 #if defined(X3270_TRACE) /*[*/
... ... @@ -508,10 +508,10 @@ proxy_telnet(int fd, char *host, unsigned short port)
508 508  
509 509 if (send(fd, buf, strlen(buf), 0) < 0) {
510 510 popup_a_sockerr(NULL,"TELNET Proxy: send error");
511   - Free(buf);
  511 + lib3270_free(buf);
512 512 return -1;
513 513 }
514   - Free(buf);
  514 + lib3270_free(buf);
515 515  
516 516 return 0;
517 517 }
... ... @@ -558,7 +558,7 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a)
558 558  
559 559 /* Send the request to the server. */
560 560 if (use_4a) {
561   - buf = Malloc(32 + strlen(user) + strlen(host));
  561 + buf = lib3270_malloc(32 + strlen(user) + strlen(host));
562 562 s = buf;
563 563 *s++ = 0x04;
564 564 *s++ = 0x01;
... ... @@ -578,14 +578,14 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a)
578 578  
579 579 if (send(fd, buf, s - buf, 0) < 0) {
580 580 popup_a_sockerr(NULL,"SOCKS4 Proxy: send error");
581   - Free(buf);
  581 + lib3270_free(buf);
582 582 return -1;
583 583 }
584   - Free(buf);
  584 + lib3270_free(buf);
585 585 } else {
586 586 unsigned long u;
587 587  
588   - buf = Malloc(32 + strlen(user));
  588 + buf = lib3270_malloc(32 + strlen(user));
589 589 s = buf;
590 590 *s++ = 0x04;
591 591 *s++ = 0x01;
... ... @@ -603,11 +603,11 @@ proxy_socks4(int fd, char *host, unsigned short port, int force_a)
603 603 #endif /*]*/
604 604  
605 605 if (send(fd, buf, s - buf, 0) < 0) {
606   - Free(buf);
  606 + lib3270_free(buf);
607 607 popup_a_sockerr(NULL,"SOCKS4 Proxy: send error");
608 608 return -1;
609 609 }
610   - Free(buf);
  610 + lib3270_free(buf);
611 611 }
612 612  
613 613 /*
... ... @@ -799,7 +799,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
799 799 }
800 800  
801 801 /* Send the request to the server. */
802   - buf = Malloc(32 + strlen(host));
  802 + buf = lib3270_malloc(32 + strlen(host));
803 803 s = buf;
804 804 *s++ = 0x05; /* protocol version 5 */
805 805 *s++ = 0x01; /* CONNECT */
... ... @@ -836,10 +836,10 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
836 836  
837 837 if (send(fd, buf, s - buf, 0) < 0) {
838 838 popup_a_sockerr(NULL,"SOCKS5 Proxy: send error");
839   - Free(buf);
  839 + lib3270_free(buf);
840 840 return -1;
841 841 }
842   - Free(buf);
  842 + lib3270_free(buf);
843 843  
844 844 /*
845 845 * Process the reply.
... ... @@ -1009,7 +1009,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
1009 1009 nbuf,
1010 1010 rport);
1011 1011 #endif /*]*/
1012   - Free(buf);
  1012 + lib3270_free(buf);
1013 1013  
1014 1014 return 0;
1015 1015 }
... ...
resources.c
... ... @@ -118,7 +118,7 @@ void add_resource(const char *name, const char *value)
118 118 return;
119 119 }
120 120 }
121   - d = Malloc(sizeof(struct dresource));
  121 + d = lib3270_malloc(sizeof(struct dresource));
122 122 d->next = NULL;
123 123 d->name = name;
124 124 d->value = value;
... ... @@ -175,7 +175,7 @@ const char * get_fresource(const char *fmt, ...)
175 175 name = xs_vsprintf(fmt, args);
176 176 va_end(args);
177 177 r = get_resource(name);
178   - Free(name);
  178 + lib3270_free(name);
179 179 return r;
180 180 }
181 181  
... ...
rpq.c
... ... @@ -282,7 +282,7 @@ select_rpq_terms(void)
282 282 * If there are override values, I'll get those from the ORIGINAL
283 283 * string so upper/lower case is preserved as necessary.
284 284 */
285   - uplist = (char *) malloc(strlen(x3270rpq)+1);
  285 + uplist = (char *) lib3270_malloc(strlen(x3270rpq)+1);
286 286 assert(uplist != NULL);
287 287 p1 = uplist;
288 288 p2 = x3270rpq;
... ... @@ -594,7 +594,7 @@ get_rpq_address(unsigned char *buf, const int maxlen)
594 594 #endif /*]*/
595 595  
596 596 p1 = x3270rpq + kw->oride;
597   - rpqtext = (char *) malloc(strlen(p1) + 1);
  597 + rpqtext = (char *) lib3270_malloc(strlen(p1) + 1);
598 598 for (p2=rpqtext;*p1; p2++) {
599 599 if (*p1 == ':')
600 600 break;
... ... @@ -729,7 +729,7 @@ static void rpq_warning(const char *fmt, ...)
729 729 {
730 730 va_start(a, fmt);
731 731 if (rpq_warnbuf == CN)
732   - rpq_warnbuf = Malloc(RPQ_WARNBUF_SIZE);
  732 + rpq_warnbuf = lib3270_malloc(RPQ_WARNBUF_SIZE);
733 733  
734 734 if (rpq_wbcnt < RPQ_WARNBUF_SIZE)
735 735 {
... ...
selection.c
... ... @@ -29,7 +29,7 @@
29 29  
30 30 #include "globals.h"
31 31 #include "appres.h"
32   - #include <malloc.h>
  32 +// #include <malloc.h>
33 33 #include <lib3270.h>
34 34 #include <lib3270/session.h>
35 35 #include <lib3270/selection.h>
... ... @@ -382,7 +382,7 @@ static char * get_text(H3270 *hSession,unsigned char all)
382 382 if(!lib3270_connected(hSession))
383 383 return NULL;
384 384  
385   - ret = malloc(buflen);
  385 + ret = lib3270_malloc(buflen);
386 386  
387 387 baddr = 0;
388 388 for(row=0;row < hSession->rows;row++)
... ... @@ -405,14 +405,14 @@ static char * get_text(H3270 *hSession,unsigned char all)
405 405  
406 406 if(!sz)
407 407 {
408   - free(ret);
  408 + lib3270_free(ret);
409 409 return NULL;
410 410 }
411 411  
412 412 ret[sz++] = 0;
413 413  
414 414 if(sz != buflen)
415   - ret = realloc(ret,sz);
  415 + ret = lib3270_realloc(ret,sz);
416 416  
417 417 return ret;
418 418 }
... ... @@ -434,7 +434,7 @@ LIB3270_EXPORT char * lib3270_get_region(H3270 *h, int start_pos, int end_pos, u
434 434 if(start_pos < 0 || start_pos > maxlen || end_pos < 0 || end_pos > maxlen || end_pos < start_pos)
435 435 return NULL;
436 436  
437   - text = malloc(maxlen);
  437 + text = lib3270_malloc(maxlen);
438 438  
439 439 for(baddr=start_pos;baddr<end_pos;baddr++)
440 440 {
... ... @@ -446,7 +446,7 @@ LIB3270_EXPORT char * lib3270_get_region(H3270 *h, int start_pos, int end_pos, u
446 446 }
447 447 text[sz++] = 0;
448 448  
449   - return realloc(text,sz);
  449 + return lib3270_realloc(text,sz);
450 450 }
451 451  
452 452 LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len)
... ... @@ -467,7 +467,7 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len)
467 467 else if(len > maxlen)
468 468 len = maxlen;
469 469  
470   - buffer = malloc(len+1);
  470 + buffer = lib3270_malloc(len+1);
471 471 ptr = buffer;
472 472  
473 473 // trace("len=%d buffer=%p",len,buffer);
... ...
telnet.c
... ... @@ -162,10 +162,7 @@ static unsigned char *sbbuf = (unsigned char *)NULL;
162 162 /* telnet sub-option buffer */
163 163 static unsigned char *sbptr;
164 164 static unsigned char telnet_state;
165   -static int syncing;
166   -#if !defined(_WIN32) /*[*/
167   -static unsigned long output_id = 0L;
168   -#endif /*]*/
  165 +// static int syncing;
169 166 static char ttype_tmpval[13];
170 167  
171 168 #if defined(X3270_TN3270E) /*[*/
... ... @@ -514,7 +511,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo
514 511 #endif
515 512  
516 513 if (netrbuf == (unsigned char *)NULL)
517   - netrbuf = (unsigned char *)Malloc(BUFSZ);
  514 + netrbuf = (unsigned char *)lib3270_malloc(BUFSZ);
518 515  
519 516 #if defined(X3270_ANSI) /*[*/
520 517 if (!t_valid)
... ... @@ -690,7 +687,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo
690 687 msg,
691 688 "%s",strerror(rc) );
692 689  
693   - Free(msg);
  690 + lib3270_free(msg);
694 691 close_fail;
695 692  
696 693 }
... ... @@ -775,8 +772,7 @@ setup_lus(void)
775 772 * Allocate enough memory to construct an argv[] array for
776 773 * the LUs.
777 774 */
778   - Replace(lus,
779   - (char **)Malloc((n_lus+1) * sizeof(char *) + strlen(h3270.luname) + 1));
  775 + Replace(lus,(char **)lib3270_malloc((n_lus+1) * sizeof(char *) + strlen(h3270.luname) + 1));
780 776  
781 777 /* Copy each LU into the array. */
782 778 lu = (char *)(lus + n_lus + 1);
... ... @@ -884,7 +880,7 @@ static void net_connected(H3270 *session)
884 880 ns_rrcvd = 0;
885 881 ns_bsent = 0;
886 882 ns_rsent = 0;
887   - syncing = 0;
  883 + session->syncing = 0;
888 884 tn3270e_negotiated = 0;
889 885 tn3270e_submode = E_NONE;
890 886 tn3270e_bound = 0;
... ... @@ -898,10 +894,10 @@ static void net_connected(H3270 *session)
898 894 {
899 895 char *buf;
900 896  
901   - buf = Malloc(strlen(session->hostname) + 32);
  897 + buf = lib3270_malloc(strlen(session->hostname) + 32);
902 898 (void) sprintf(buf, "%s %d\r\n", session->hostname, session->current_port);
903 899 (void) send(session->sock, buf, strlen(buf), 0);
904   - Free(buf);
  900 + lib3270_free(buf);
905 901 }
906 902 }
907 903  
... ... @@ -956,14 +952,17 @@ void net_disconnect(H3270 *session)
956 952 session->connected_lu = CN;
957 953 status_lu(&h3270,CN);
958 954  
959   -#if !defined(_WIN32) /*[*/
960   - /* We have no more interest in output buffer space. */
961   - if (output_id != 0L)
  955 +/*
  956 +#if !defined(_WIN32)
  957 + // We have no more interest in output buffer space.
  958 + if(session->output_id != NULL)
962 959 {
963   - RemoveInput(output_id);
964   - output_id = 0L;
  960 + RemoveInput(session->output_id);
  961 + session->output_id = NULL;
965 962 }
966   -#endif /*]*/
  963 +#endif
  964 +*/
  965 +
967 966 }
968 967  
969 968  
... ... @@ -1232,7 +1231,8 @@ telnet_fsm(unsigned char c)
1232 1231 ansi_data = 4 + sl;
1233 1232 }
1234 1233 trace_dsn("%s",see_chr);
1235   - if (!syncing) {
  1234 + if (!h3270.syncing)
  1235 + {
1236 1236 if (linemode && h3270.onlcr && c == '\n')
1237 1237 ansi_process((unsigned int) '\r');
1238 1238 ansi_process((unsigned int) c);
... ... @@ -1295,14 +1295,14 @@ telnet_fsm(unsigned char c)
1295 1295 case SB:
1296 1296 telnet_state = TNS_SB;
1297 1297 if (sbbuf == (unsigned char *)NULL)
1298   - sbbuf = (unsigned char *)Malloc(1024);
  1298 + sbbuf = (unsigned char *)lib3270_malloc(1024);
1299 1299 sbptr = sbbuf;
1300 1300 break;
1301 1301 case DM:
1302 1302 trace_dsn("\n");
1303   - if (syncing)
  1303 + if (h3270.syncing)
1304 1304 {
1305   - syncing = 0;
  1305 + h3270.syncing = 0;
1306 1306 x_except_on(&h3270);
1307 1307 }
1308 1308 telnet_state = TNS_DATA;
... ... @@ -1480,7 +1480,7 @@ telnet_fsm(unsigned char c)
1480 1480 status_lu(&h3270,h3270.connected_lu);
1481 1481  
1482 1482 tb_len = 4 + tt_len + 2;
1483   - tt_out = Malloc(tb_len + 1);
  1483 + tt_out = lib3270_malloc(tb_len + 1);
1484 1484 (void) sprintf(tt_out, "%c%c%c%c%s%s%s%c%c",
1485 1485 IAC, SB, TELOPT_TTYPE, TELQUAL_IS,
1486 1486 h3270.termtype,
... ... @@ -1494,7 +1494,7 @@ telnet_fsm(unsigned char c)
1494 1494 telquals[TELQUAL_IS],
1495 1495 tt_len, tt_out + 4,
1496 1496 cmd(SE));
1497   - Free(tt_out);
  1497 + lib3270_free(tt_out);
1498 1498  
1499 1499 /* Advance to the next LU name. */
1500 1500 next_lu();
... ... @@ -1536,7 +1536,7 @@ tn3270e_request(void)
1536 1536 tt_len += strlen(try_lu) + 1;
1537 1537  
1538 1538 tb_len = 5 + tt_len + 2;
1539   - tt_out = Malloc(tb_len + 1);
  1539 + tt_out = lib3270_malloc(tb_len + 1);
1540 1540 t = tt_out;
1541 1541 t += sprintf(tt_out, "%c%c%c%c%c%s",
1542 1542 IAC, SB, TELOPT_TN3270E, TN3270E_OP_DEVICE_TYPE,
... ... @@ -1559,7 +1559,7 @@ tn3270e_request(void)
1559 1559 (try_lu != CN && *try_lu) ? try_lu : "",
1560 1560 cmd(SE));
1561 1561  
1562   - Free(tt_out);
  1562 + lib3270_free(tt_out);
1563 1563 }
1564 1564  
1565 1565 /*
... ... @@ -1884,7 +1884,7 @@ process_bind(unsigned char *buf, int buflen)
1884 1884 static int
1885 1885 process_eor(void)
1886 1886 {
1887   - if (syncing || !(ibptr - ibuf))
  1887 + if (h3270.syncing || !(ibptr - ibuf))
1888 1888 return(0);
1889 1889  
1890 1890 #if defined(X3270_TN3270E) /*[*/
... ... @@ -1968,15 +1968,17 @@ process_eor(void)
1968 1968 */
1969 1969 void net_exception(H3270 *session)
1970 1970 {
  1971 + CHECK_SESSION_HANDLE(session);
  1972 +
1971 1973 trace_dsn("RCVD urgent data indication\n");
1972   - if (!syncing)
  1974 + if (!session->syncing)
1973 1975 {
1974   - syncing = 1;
  1976 + session->syncing = 1;
1975 1977  
1976 1978 if(session->excepting)
1977 1979 {
1978 1980 RemoveInput(session->ns_exception_id);
1979   - session->excepting = False;
  1981 + session->excepting = 0;
1980 1982 }
1981 1983 // x_except_off(session);
1982 1984 }
... ... @@ -2105,7 +2107,7 @@ net_hexansi_out(unsigned char *buf, int len)
2105 2107 #endif /*]*/
2106 2108  
2107 2109 /* Expand it. */
2108   - tbuf = xbuf = (unsigned char *)Malloc(2*len);
  2110 + tbuf = xbuf = (unsigned char *)lib3270_malloc(2*len);
2109 2111 while (len) {
2110 2112 unsigned char c = *buf++;
2111 2113  
... ... @@ -2119,7 +2121,7 @@ net_hexansi_out(unsigned char *buf, int len)
2119 2121  
2120 2122 /* Send it to the host. */
2121 2123 net_rawout(xbuf, tbuf - xbuf);
2122   - Free(xbuf);
  2124 + lib3270_free(xbuf);
2123 2125 }
2124 2126  
2125 2127 /*
... ... @@ -2212,7 +2214,7 @@ static void
2212 2214 cooked_init(void)
2213 2215 {
2214 2216 if (lbuf == (unsigned char *)NULL)
2215   - lbuf = (unsigned char *)Malloc(BUFSZ);
  2217 + lbuf = (unsigned char *)lib3270_malloc(BUFSZ);
2216 2218 lbptr = lbuf;
2217 2219 lnext = 0;
2218 2220 backslashed = 0;
... ... @@ -2486,7 +2488,7 @@ check_in3270(void)
2486 2488  
2487 2489 /* Allocate the initial 3270 input buffer. */
2488 2490 if (new_cstate >= CONNECTED_INITIAL && !ibuf_size) {
2489   - ibuf = (unsigned char *)Malloc(BUFSIZ);
  2491 + ibuf = (unsigned char *)lib3270_malloc(BUFSIZ);
2490 2492 ibuf_size = BUFSIZ;
2491 2493 ibptr = ibuf;
2492 2494 }
... ... @@ -2726,7 +2728,7 @@ net_output(void)
2726 2728 need_resize++;
2727 2729 }
2728 2730 if (need_resize) {
2729   - Replace(xobuf, (unsigned char *)Malloc(xobuf_len));
  2731 + Replace(xobuf, (unsigned char *)lib3270_malloc(xobuf_len));
2730 2732 }
2731 2733  
2732 2734 /* Copy and expand IACs. */
... ...
trace_ds.c
... ... @@ -421,7 +421,7 @@ static char * create_tracefile_header(const char *mode)
421 421 time_t clk;
422 422  
423 423 // Create a buffer and redirect output.
424   - buf = Malloc(MAX_HEADER_SIZE);
  424 + buf = lib3270_malloc(MAX_HEADER_SIZE);
425 425 tracef_bufptr = buf;
426 426  
427 427 // Display current status
... ... @@ -583,7 +583,7 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d
583 583 if (strchr(tfn, '\'') || ((int)strlen(tfn) > 0 && tfn[strlen(tfn)-1] == '\\'))
584 584 {
585 585 popup_an_error("Illegal file name: %s", tfn);
586   - Free(tfn);
  586 + lib3270_free(tfn);
587 587 return;
588 588 }
589 589  
... ... @@ -604,7 +604,7 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d
604 604 if (tracef_max && !access(tfn, R_OK))
605 605 {
606 606 popup_an_error("Trace file '%s' already exists",tfn);
607   - Free(tfn);
  607 + lib3270_free(tfn);
608 608 return;
609 609 }
610 610  
... ... @@ -616,7 +616,7 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d
616 616 if (tracef == (FILE *)NULL)
617 617 {
618 618 popup_an_errno(errno, tfn);
619   - Free(tfn);
  619 + lib3270_free(tfn);
620 620 return;
621 621 }
622 622 (void) SETLINEBUF(tracef);
... ... @@ -629,7 +629,7 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d
629 629 if(!tracewindow_handle)
630 630 tracewindow_handle = console_window_new( tfn, NULL );
631 631  
632   - Free(tfn);
  632 + lib3270_free(tfn);
633 633  
634 634 // We're really tracing, turn the flag on.
635 635 appres.toggle[trace_reason].value = True;
... ... @@ -639,7 +639,7 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d
639 639 // Display current status
640 640 buf = create_tracefile_header("started");
641 641 wtrace("%s", buf);
642   - Free(buf);
  642 + lib3270_free(buf);
643 643  
644 644 }
645 645  
... ... @@ -696,7 +696,7 @@ tracefile_on(int reason, LIB3270_TOGGLE_TYPE tt)
696 696 {
697 697 tracefile_callback((Widget)NULL, tracefile, PN);
698 698 if (tracefile_buf != NULL)
699   - Free(tracefile_buf);
  699 + lib3270_free(tracefile_buf);
700 700 return;
701 701 }
702 702 #if defined(X3270_DISPLAY)
... ... @@ -718,7 +718,7 @@ tracefile_on(int reason, LIB3270_TOGGLE_TYPE tt)
718 718 #endif
719 719  
720 720 if (tracefile_buf != NULL)
721   - Free(tracefile_buf);
  721 + lib3270_free(tracefile_buf);
722 722 }
723 723  
724 724 // Close the trace file.
... ... @@ -856,10 +856,10 @@ screentrace_cb(char *tfn)
856 856 screentracef = fopen(tfn, "a");
857 857 if (screentracef == (FILE *)NULL) {
858 858 popup_an_errno(errno, tfn);
859   - Free(tfn);
  859 + lib3270_free(tfn);
860 860 return False;
861 861 }
862   - Free(tfn);
  862 + lib3270_free(tfn);
863 863 (void) SETLINEBUF(screentracef);
864 864 #if !defined(_WIN32)
865 865 (void) fcntl(fileno(screentracef), F_SETFD, 1);
... ... @@ -941,7 +941,7 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_
941 941 if (tt == TT_INITIAL || tt == TT_ACTION) {
942 942 (void) screentrace_cb(NewString(tracefile));
943 943 if (tracefile_buf != NULL)
944   - Free(tracefile_buf);
  944 + lib3270_free(tracefile_buf);
945 945 return;
946 946 }
947 947 #if defined(X3270_DISPLAY)
... ... @@ -965,7 +965,7 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_
965 965 }
966 966  
967 967 if (tracefile_buf != NULL)
968   - Free(tracefile_buf);
  968 + lib3270_free(tracefile_buf);
969 969 }
970 970 */
971 971  
... ...
utf8.c
... ... @@ -432,7 +432,7 @@ utf8_set_display_charsets(char *cslist, char *csname)
432 432 }
433 433 if (tok == CN) {
434 434 popup_an_error(NULL,"Invalid displayCharset specification");
435   - Free(dup);
  435 + lib3270_free(dup);
436 436 return False;
437 437 }
438 438  
... ... @@ -444,11 +444,11 @@ utf8_set_display_charsets(char *cslist, char *csname)
444 444 if (dcs[i] == CN) {
445 445 popup_an_error(NULL,"Unknown displayCharset specification '%s'",
446 446 csname);
447   - Free(dup);
  447 + lib3270_free(dup);
448 448 return False;
449 449 }
450 450 utf8_ix = i;
451   - Free(dup);
  451 + lib3270_free(dup);
452 452 return True;
453 453 }
454 454 */
... ...
util.c
... ... @@ -54,6 +54,10 @@
54 54 #include <pwd.h>
55 55 #endif // _WIN32
56 56  
  57 +#ifdef HAVE_MALLOC_H
  58 + #include <malloc.h>
  59 +#endif
  60 +
57 61 #ifndef ANDROID
58 62 #include <stdlib.h>
59 63 #endif // !ANDROID
... ... @@ -177,7 +181,7 @@ char * xs_vsprintf(const char *fmt, va_list args)
177 181 nc = vsprintf(buf, fmt, args);
178 182 if (nc > sizeof(buf))
179 183 Error(NULL,"Internal buffer overflow");
180   - r = Malloc(nc + 1);
  184 + r = lib3270_malloc(nc + 1);
181 185 return strcpy(r, buf);
182 186 #endif /*]*/
183 187 }
... ... @@ -210,7 +214,7 @@ xs_warning(const char *fmt, ...)
210 214 r = xs_vsprintf(fmt, args);
211 215 va_end(args);
212 216 Warning(NULL,r);
213   - Free(r);
  217 + lib3270_free(r);
214 218 }
215 219  
216 220 void
... ... @@ -223,7 +227,7 @@ xs_error(const char *fmt, ...)
223 227 r = xs_vsprintf(fmt, args);
224 228 va_end(args);
225 229 Error(NULL,r);
226   - Free(r);
  230 + lib3270_free(r);
227 231 }
228 232  
229 233 /* Prettyprinter for strings with unprintable data. */
... ... @@ -406,11 +410,11 @@ split_dbcs_resource(const char *value, char sep, char **part1, char **part2)
406 410 if (f_end == f_start) {
407 411 if (c == sep) {
408 412 if (*part1) {
409   - Free(*part1);
  413 + lib3270_free(*part1);
410 414 *part1 = NULL;
411 415 }
412 416 if (*part2) {
413   - Free(*part2);
  417 + lib3270_free(*part2);
414 418 *part2 = NULL;
415 419 }
416 420 return -1;
... ... @@ -427,7 +431,7 @@ split_dbcs_resource(const char *value, char sep, char **part1, char **part2)
427 431 default:
428 432 return 3;
429 433 }
430   - *rp = Malloc(f_end - f_start + 1);
  434 + *rp = lib3270_malloc(f_end - f_start + 1);
431 435 strncpy(*rp, f_start, f_end - f_start);
432 436 (*rp)[f_end - f_start] = '\0';
433 437 f_end = CN;
... ... @@ -539,7 +543,7 @@ var_subst(const char *s)
539 543 return NewString(s);
540 544  
541 545 o_len = strlen(s) + 1;
542   - ob = Malloc(o_len);
  546 + ob = lib3270_malloc(o_len);
543 547 o = ob;
544 548 # define LBR '{'
545 549 # define RBR '}'
... ... @@ -604,7 +608,7 @@ var_subst(const char *s)
604 608 state = VS_BASE;
605 609 continue; /* rescan */
606 610 }
607   - vn = Malloc(vn_len + 1);
  611 + vn = lib3270_malloc(vn_len + 1);
608 612 (void) strncpy(vn, vn_start, vn_len);
609 613 vn[vn_len] = '\0';
610 614  
... ... @@ -625,7 +629,7 @@ var_subst(const char *s)
625 629 }
626 630 #endif // !ANDROID
627 631  
628   - Free(vn);
  632 + lib3270_free(vn);
629 633 if (state == VS_VNB) {
630 634 state = VS_BASE;
631 635 break;
... ... @@ -670,7 +674,7 @@ tilde_subst(const char *s)
670 674 if (slash) {
671 675 int len = slash - s;
672 676  
673   - mname = Malloc(len + 1);
  677 + mname = lib3270_malloc(len + 1);
674 678 (void) strncpy(mname, s, len);
675 679 mname[len] = '\0';
676 680 name = mname;
... ... @@ -687,13 +691,13 @@ tilde_subst(const char *s)
687 691 p = getpwnam(name + 1);
688 692  
689 693 /* Free any temporary copy. */
690   - Free(mname);
  694 + lib3270_free(mname);
691 695  
692 696 /* Substitute and return. */
693 697 if (p == (struct passwd *)NULL)
694 698 r = NewString(s);
695 699 else {
696   - r = Malloc(strlen(p->pw_dir) + strlen(rest) + 1);
  700 + r = lib3270_malloc(strlen(p->pw_dir) + strlen(rest) + 1);
697 701 (void) strcpy(r, p->pw_dir);
698 702 (void) strcat(r, rest);
699 703 }
... ... @@ -716,7 +720,7 @@ do_subst(const char *s, Boolean do_vars, Boolean do_tilde)
716 720 char *u;
717 721  
718 722 u = tilde_subst(t);
719   - Free(t);
  723 + lib3270_free(t);
720 724 return u;
721 725 }
722 726 #endif /*]*/
... ... @@ -871,7 +875,7 @@ rpf(rpf_t *r, char *fmt, ...)
871 875 void
872 876 rpf_free(rpf_t *r)
873 877 {
874   - Free(r->buf);
  878 + lib3270_free(r->buf);
875 879 r->buf = NULL;
876 880 r->alloc_len = 0;
877 881 r->cur_len = 0;
... ...