Use g_new or g_new0 when C++ compiler would complain about implicit cast
This commit is contained in:
parent
a24df49241
commit
5829323ad8
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user