diff options
author | Pavel Roskin <plroskin@gmail.com> | 2016-06-21 16:30:18 -0700 |
---|---|---|
committer | Pavel Roskin <plroskin@gmail.com> | 2016-07-08 04:29:49 +0000 |
commit | 5829323ad88f8120730968cfe165e590a7fb2d59 (patch) | |
tree | b5e13986d78de530a0a2168efdb95062e2803aca | |
parent | a24df49241adc7c49dff777742d668f1d6c690ad (diff) | |
download | xrdp-proprietary-5829323ad88f8120730968cfe165e590a7fb2d59.tar.gz xrdp-proprietary-5829323ad88f8120730968cfe165e590a7fb2d59.zip |
Use g_new or g_new0 when C++ compiler would complain about implicit cast
-rw-r--r-- | common/log.c | 2 | ||||
-rw-r--r-- | common/ssl_calls.c | 2 | ||||
-rw-r--r-- | sesman/chansrv/chansrv.c | 2 | ||||
-rw-r--r-- | sesman/chansrv/devredir.c | 8 | ||||
-rw-r--r-- | sesman/chansrv/irp.c | 3 | ||||
-rw-r--r-- | sesman/chansrv/rail.c | 2 | ||||
-rw-r--r-- | sesman/chansrv/smartcard.c | 3 | ||||
-rw-r--r-- | sesman/chansrv/smartcard_pcsc.c | 4 | ||||
-rw-r--r-- | sesman/libscp/libscp_connection.c | 2 | ||||
-rw-r--r-- | sesman/libscp/libscp_v1c.c | 8 | ||||
-rw-r--r-- | sesman/libscp/libscp_v1c_mng.c | 2 | ||||
-rw-r--r-- | sesman/sesman.c | 2 | ||||
-rw-r--r-- | sesman/session.c | 4 | ||||
-rw-r--r-- | sesman/sig.c | 2 | ||||
-rw-r--r-- | sesman/verify_user_pam.c | 4 | ||||
-rw-r--r-- | xrdp/xrdp_mm.c | 4 | ||||
-rw-r--r-- | xrdp/xrdp_wm.c | 2 | ||||
-rw-r--r-- | xup/xup.c | 2 |
18 files changed, 31 insertions, 27 deletions
diff --git a/common/log.c b/common/log.c index 1338287a..77bcc6d6 100644 --- a/common/log.c +++ b/common/log.c @@ -395,7 +395,7 @@ enum logReturns DEFAULT_CC internalInitAndAllocStruct(void) { enum logReturns ret = LOG_GENERAL_ERROR; - g_staticLogConfig = g_malloc(sizeof(struct log_config), 1); + g_staticLogConfig = g_new0(struct log_config, 1); if (g_staticLogConfig != NULL) { diff --git a/common/ssl_calls.c b/common/ssl_calls.c index 3d9e1c2e..e3d3e67e 100644 --- a/common/ssl_calls.c +++ b/common/ssl_calls.c @@ -187,7 +187,7 @@ ssl_des3_decrypt_info_create(const char *key, const char* ivec) const tui8 *lkey; const tui8 *livec; - des3_ctx = g_malloc(sizeof(EVP_CIPHER_CTX), 1); + des3_ctx = g_new0(EVP_CIPHER_CTX, 1); EVP_CIPHER_CTX_init(des3_ctx); lkey = (const tui8 *) key; livec = (const tui8 *) ivec; diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index c1f41499..a521581d 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -97,7 +97,7 @@ add_timeout(int msoffset, void (*callback)(void *data), void *data) LOG(10, ("add_timeout:")); now = g_time3(); - tobj = g_malloc(sizeof(struct timeout_obj), 1); + tobj = g_new0(struct timeout_obj, 1); tobj->mstime = now + msoffset; tobj->callback = callback; tobj->data = data; diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index c29c7e43..bb10a6c9 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -962,7 +962,8 @@ dev_redir_proc_query_dir_response(IRP *irp, //log_debug("FileNameLength: %d", FileNameLength); log_debug("FileName: %s", filename); - if ((xinode = calloc(1, sizeof(struct xrdp_inode))) == NULL) + xinode = g_new0(struct xrdp_inode, 1); + if (xinode == NULL) { log_error("system out of memory"); fuse_data = devredir_fuse_data_peek(irp); @@ -1378,7 +1379,8 @@ devredir_fuse_data_enqueue(IRP *irp, void *vp) if (irp == NULL) return -1; - if ((fd = calloc(1, sizeof(FUSE_DATA))) == NULL) + fd = g_new0(FUSE_DATA, 1); + if (fd == NULL) return -1; fd->data_ptr = vp; @@ -1481,7 +1483,7 @@ devredir_cvt_from_unicode_len(char *path, char *unicode, int len) bytes_to_alloc = (((len / 2) * sizeof(twchar)) + sizeof(twchar)); src = unicode; - dest = g_malloc(bytes_to_alloc, 1); + dest = g_new0(char, bytes_to_alloc); dest_saved = dest; for (i = 0; i < len; i += 2) diff --git a/sesman/chansrv/irp.c b/sesman/chansrv/irp.c index 2a5209d8..ad318cb1 100644 --- a/sesman/chansrv/irp.c +++ b/sesman/chansrv/irp.c @@ -77,7 +77,8 @@ IRP * devredir_irp_new() log_debug("entered"); /* create new IRP */ - if ((irp = g_malloc(sizeof(IRP), 1)) == NULL) + irp = g_new0(IRP, 1); + if (irp == NULL) { log_error("system out of memory!"); return NULL; diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 8a23973a..36e39889 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -238,7 +238,7 @@ rail_get_window_data_safe(Window window) { return rv; } - rv = g_malloc(sizeof(struct rail_window_data), 1); + rv = g_new0(struct rail_window_data, 1); rail_set_window_data(window, rv); g_free(rv); return rail_get_window_data(window); diff --git a/sesman/chansrv/smartcard.c b/sesman/chansrv/smartcard.c index 38d80c8b..1e692909 100644 --- a/sesman/chansrv/smartcard.c +++ b/sesman/chansrv/smartcard.c @@ -900,7 +900,8 @@ scard_add_new_device(tui32 device_id) return -1; } - if ((sc = g_malloc(sizeof(SMARTCARD), 1)) == NULL) + sc = g_new0(SMARTCARD, 1); + if (sc == NULL) { log_error("system out of memory"); return -1; diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index bf3d11bb..16938bf9 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -97,7 +97,7 @@ create_uds_client(struct trans *con) { return 0; } - uds_client = g_malloc(sizeof(struct pcsc_uds_client), 1); + uds_client = g_new0(struct pcsc_uds_client, 1); if (uds_client == 0) { return 0; @@ -606,7 +606,7 @@ scard_process_list_readers(struct trans *con, struct stream *in_s) g_free(groups); return 1; } - pcscListReaders = g_malloc(sizeof(struct pcsc_list_readers), 1); + pcscListReaders = g_new0(struct pcsc_list_readers, 1); pcscListReaders->uds_client_id = uds_client->uds_client_id; pcscListReaders->cchReaders = cchReaders; scard_send_list_readers(pcscListReaders, lcontext->context, diff --git a/sesman/libscp/libscp_connection.c b/sesman/libscp/libscp_connection.c index 6366d51a..a04c4388 100644 --- a/sesman/libscp/libscp_connection.c +++ b/sesman/libscp/libscp_connection.c @@ -33,7 +33,7 @@ scp_connection_create(int sck) { struct SCP_CONNECTION *conn; - conn = g_malloc(sizeof(struct SCP_CONNECTION), 0); + conn = g_new(struct SCP_CONNECTION, 1); if (0 == conn) { diff --git a/sesman/libscp/libscp_v1c.c b/sesman/libscp/libscp_v1c.c index 7d1b9db8..7bc9a1d3 100644 --- a/sesman/libscp/libscp_v1c.c +++ b/sesman/libscp/libscp_v1c.c @@ -224,7 +224,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION *c, int *scount, in_uint32_be(c->in_s, sescnt); sestmp = sescnt; - ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0); + ds = g_new(struct SCP_DISCONNECTED_SESSION, sescnt); if (ds == 0) { @@ -429,7 +429,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s) g_free(s->errstr); } - s->errstr = g_malloc(dim + 1, 0); + s->errstr = g_new(char, dim + 1); if (s->errstr == 0) { @@ -450,7 +450,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s) g_free(s->errstr); } - s->errstr = g_malloc(dim + 1, 0); + s->errstr = g_new(char, dim + 1); if (s->errstr == 0) { @@ -471,7 +471,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION *c, struct SCP_SESSION *s) g_free(s->errstr); } - s->errstr = g_malloc(dim + 1, 0); + s->errstr = g_new(char, dim + 1); if (s->errstr == 0) { diff --git a/sesman/libscp/libscp_v1c_mng.c b/sesman/libscp/libscp_v1c_mng.c index 59762e36..d9b43b98 100644 --- a/sesman/libscp/libscp_v1c_mng.c +++ b/sesman/libscp/libscp_v1c_mng.c @@ -199,7 +199,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION *c, int *scount, return SCP_CLIENT_STATE_LIST_OK; } - ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0); + ds = g_new(struct SCP_DISCONNECTED_SESSION, sescnt); if (ds == 0) { diff --git a/sesman/sesman.c b/sesman/sesman.c index 828524fa..c9666943 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -247,7 +247,7 @@ main(int argc, char **argv) } /* reading config */ - g_cfg = g_malloc(sizeof(struct config_sesman), 1); + g_cfg = g_new0(struct config_sesman, 1); if (0 == g_cfg) { diff --git a/sesman/session.c b/sesman/session.c index 28e00fc9..79128e5e 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -959,7 +959,7 @@ session_get_bypid(int pid) struct session_chain *tmp; struct session_item *dummy; - dummy = g_malloc(sizeof(struct session_item), 1); + dummy = g_new0(struct session_item, 1); if (0 == dummy) { @@ -1033,7 +1033,7 @@ session_get_byuser(char *user, int *cnt, unsigned char flags) } /* malloc() an array of disconnected sessions */ - sess = g_malloc(count *sizeof(struct SCP_DISCONNECTED_SESSION), 1); + sess = g_new0(struct SCP_DISCONNECTED_SESSION, count); if (sess == 0) { diff --git a/sesman/sig.c b/sesman/sig.c index b10be5fb..3cc3395a 100644 --- a/sesman/sig.c +++ b/sesman/sig.c @@ -75,7 +75,7 @@ sig_sesman_reload_cfg(int sig) return; } - cfg = g_malloc(sizeof(struct config_sesman), 1); + cfg = g_new0(struct config_sesman, 1); if (0 == cfg) { diff --git a/sesman/verify_user_pam.c b/sesman/verify_user_pam.c index 29f21225..43783211 100644 --- a/sesman/verify_user_pam.c +++ b/sesman/verify_user_pam.c @@ -54,7 +54,7 @@ verify_pam_conv(int num_msg, const struct pam_message **msg, struct pam_response *reply; struct t_user_pass *user_pass; - reply = g_malloc(sizeof(struct pam_response) * num_msg, 1); + reply = g_new0(struct pam_response, num_msg); for (i = 0; i < num_msg; i++) { @@ -109,7 +109,7 @@ auth_userpass(char *user, char *pass, int *errorcode) char service_name[256]; get_service_name(service_name); - auth_info = g_malloc(sizeof(struct t_auth_info), 1); + auth_info = g_new0(struct t_auth_info, 1); g_strncpy(auth_info->user_pass.user, user, 255); g_strncpy(auth_info->user_pass.pass, pass, 255); auth_info->pamc.conv = &verify_pam_conv; diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index dfc04152..f1a01efa 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -764,7 +764,7 @@ xrdp_mm_process_rail_create_window(struct xrdp_mm* self, struct stream* s) in_uint16_le(s, title_bytes); if (title_bytes > 0) { - rwso.title_info = g_malloc(title_bytes + 1, 0); + rwso.title_info = g_new(char, title_bytes + 1); in_uint8a(s, rwso.title_info, title_bytes); rwso.title_info[title_bytes] = 0; } @@ -947,7 +947,7 @@ xrdp_mm_process_rail_update_window_text(struct xrdp_mm* self, struct stream* s) g_memset(&rwso, 0, sizeof(rwso)); in_uint32_le(s, size); /* title size */ - rwso.title_info = g_malloc(size + 1, 0); + rwso.title_info = g_new(char, size + 1); in_uint8a(s, rwso.title_info, size); rwso.title_info[size] = 0; g_writeln(" set window title %s size %d 0x%8.8x", rwso.title_info, size, flags); diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 3bb326f3..548742ac 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -62,7 +62,7 @@ xrdp_wm_create(struct xrdp_process *owner, self->current_surface_index = 0xffff; /* screen */ /* to store configuration from xrdp.ini */ - self->xrdp_config = g_malloc(sizeof(struct xrdp_config), 1); + self->xrdp_config = g_new0(struct xrdp_config, 1); return self; } @@ -697,7 +697,7 @@ process_server_window_new_update(struct mod *mod, struct stream *s) if (title_bytes > 0) { - rwso.title_info = g_malloc(title_bytes + 1, 0); + rwso.title_info = g_new(char, title_bytes + 1); in_uint8a(s, rwso.title_info, title_bytes); rwso.title_info[title_bytes] = 0; } |