diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 08404f104667..2575661c8eb0 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -380,7 +380,8 @@ static int audin_on_new_channel_connection(IWTSListenerCallback* pListenerCallba DEBUG_DVC(""); - callback = xnew(AUDIN_CHANNEL_CALLBACK); + callback = (AUDIN_CHANNEL_CALLBACK*) malloc(sizeof(AUDIN_CHANNEL_CALLBACK)); + ZeroMemory(callback, sizeof(AUDIN_CHANNEL_CALLBACK)); callback->iface.OnDataReceived = audin_on_data_received; callback->iface.OnClose = audin_on_close; @@ -399,7 +400,8 @@ static int audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage DEBUG_DVC(""); - audin->listener_callback = xnew(AUDIN_LISTENER_CALLBACK); + audin->listener_callback = (AUDIN_LISTENER_CALLBACK*) malloc(sizeof(AUDIN_LISTENER_CALLBACK)); + ZeroMemory(audin->listener_callback, sizeof(AUDIN_LISTENER_CALLBACK)); audin->listener_callback->iface.OnNewChannelConnection = audin_on_new_channel_connection; audin->listener_callback->plugin = pPlugin; diff --git a/channels/client/channels.c b/channels/client/channels.c index 4f4b84deb3a9..45fa8c400330 100644 --- a/channels/client/channels.c +++ b/channels/client/channels.c @@ -930,7 +930,8 @@ rdpChannels* freerdp_channels_new(void) rdpChannels* channels; rdpChannelsList* channels_list; - channels = xnew(rdpChannels); + channels = (rdpChannels*) malloc(sizeof(rdpChannels)); + ZeroMemory(channels, sizeof(rdpChannels)); channels->pSyncDataList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT); InitializeSListHead(channels->pSyncDataList); @@ -939,7 +940,8 @@ rdpChannels* freerdp_channels_new(void) channels->signal = wait_obj_new(); /* Add it to the global list */ - channels_list = xnew(rdpChannelsList); + channels_list = (rdpChannelsList*) malloc(sizeof(rdpChannelsList)); + ZeroMemory(channels_list, sizeof(rdpChannelsList)); channels_list->channels = channels; WaitForSingleObject(g_mutex_list, INFINITE); diff --git a/channels/drdynvc/client/dvcman.c b/channels/drdynvc/client/dvcman.c index 39c6385b0aaa..a5631ee73c3e 100644 --- a/channels/drdynvc/client/dvcman.c +++ b/channels/drdynvc/client/dvcman.c @@ -102,13 +102,16 @@ static int dvcman_create_listener(IWTSVirtualChannelManager* pChannelMgr, const char* pszChannelName, UINT32 ulFlags, IWTSListenerCallback* pListenerCallback, IWTSListener** ppListener) { - DVCMAN* dvcman = (DVCMAN*)pChannelMgr; + DVCMAN* dvcman = (DVCMAN*) pChannelMgr; DVCMAN_LISTENER* listener; if (dvcman->num_listeners < MAX_PLUGINS) { DEBUG_DVC("%d.%s.", dvcman->num_listeners, pszChannelName); - listener = xnew(DVCMAN_LISTENER); + + listener = (DVCMAN_LISTENER*) malloc(sizeof(DVCMAN_LISTENER)); + ZeroMemory(listener, sizeof(DVCMAN_LISTENER)); + listener->iface.GetConfiguration = dvcman_get_configuration; listener->dvcman = dvcman; listener->channel_name = _strdup(pszChannelName); @@ -213,7 +216,9 @@ IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin) { DVCMAN* dvcman; - dvcman = xnew(DVCMAN); + dvcman = (DVCMAN*) malloc(sizeof(DVCMAN)); + ZeroMemory(dvcman, sizeof(DVCMAN)); + dvcman->iface.CreateListener = dvcman_create_listener; dvcman->iface.PushEvent = dvcman_push_event; dvcman->iface.FindChannelById = dvcman_find_channel_by_id; @@ -345,7 +350,9 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 Channel if (strcmp(listener->channel_name, ChannelName) == 0) { - channel = xnew(DVCMAN_CHANNEL); + channel = (DVCMAN_CHANNEL*) malloc(sizeof(DVCMAN_CHANNEL)); + ZeroMemory(channel, sizeof(DVCMAN_CHANNEL)); + channel->iface.Write = dvcman_write_channel; channel->iface.Close = dvcman_close_channel_iface; channel->dvcman = dvcman; diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index d9907a08eeb5..df20bd70b79e 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -291,7 +291,9 @@ DRIVE_FILE* drive_file_new(const char* base_path, const char* path, UINT32 id, { DRIVE_FILE* file; - file = xnew(DRIVE_FILE); + file = (DRIVE_FILE*) malloc(sizeof(DRIVE_FILE)); + ZeroMemory(file, sizeof(DRIVE_FILE)); + file->id = id; file->basepath = (char*) base_path; drive_file_set_fullpath(file, drive_file_combine_fullpath(base_path, path)); diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index 685566571f31..43c1cfd778a1 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -325,7 +325,8 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) if (name[0] && path[0]) { - parallel = xnew(PARALLEL_DEVICE); + parallel = (PARALLEL_DEVICE*) malloc(sizeof(PARALLEL_DEVICE)); + ZeroMemory(parallel, sizeof(PARALLEL_DEVICE)); parallel->device.type = RDPDR_DTYP_PARALLEL; parallel->device.name = name; diff --git a/channels/printer/client/printer_cups.c b/channels/printer/client/printer_cups.c index 2384b5f4e643..4c0441e271a6 100644 --- a/channels/printer/client/printer_cups.c +++ b/channels/printer/client/printer_cups.c @@ -79,36 +79,39 @@ static void printer_cups_get_printjob_name(char* buf, int size) static void printer_cups_write_printjob(rdpPrintJob* printjob, BYTE* data, int size) { - rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*)printjob; + rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*) printjob; #ifndef _CUPS_API_1_4 { FILE* fp; - fp = fopen((const char*)cups_printjob->printjob_object, "a+b"); + fp = fopen((const char*) cups_printjob->printjob_object, "a+b"); + if (fp == NULL) { - DEBUG_WARN("failed to open file %s", (char*)cups_printjob->printjob_object); + DEBUG_WARN("failed to open file %s", (char*) cups_printjob->printjob_object); return; } + if (fwrite(data, 1, size, fp) < size) { - DEBUG_WARN("failed to write file %s", (char*)cups_printjob->printjob_object); + DEBUG_WARN("failed to write file %s", (char*) cups_printjob->printjob_object); } + fclose(fp); } #else - cupsWriteRequestData((http_t*)cups_printjob->printjob_object, (const char*)data, size); + cupsWriteRequestData((http_t*) cups_printjob->printjob_object, (const char*) data, size); #endif } static void printer_cups_close_printjob(rdpPrintJob* printjob) { - rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*)printjob; + rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*) printjob; #ifndef _CUPS_API_1_4 @@ -116,35 +119,38 @@ static void printer_cups_close_printjob(rdpPrintJob* printjob) char buf[100]; printer_cups_get_printjob_name(buf, sizeof(buf)); - if (cupsPrintFile(printjob->printer->name, (const char *)cups_printjob->printjob_object, buf, 0, NULL) == 0) + + if (cupsPrintFile(printjob->printer->name, (const char*) cups_printjob->printjob_object, buf, 0, NULL) == 0) { DEBUG_WARN("cupsPrintFile: %s", cupsLastErrorString()); } + unlink(cups_printjob->printjob_object); free(cups_printjob->printjob_object); } #else - cupsFinishDocument((http_t*)cups_printjob->printjob_object, printjob->printer->name); + cupsFinishDocument((http_t*) cups_printjob->printjob_object, printjob->printer->name); cups_printjob->printjob_id = 0; - httpClose((http_t*)cups_printjob->printjob_object); + httpClose((http_t*) cups_printjob->printjob_object); #endif - ((rdpCupsPrinter*)printjob->printer)->printjob = NULL; + ((rdpCupsPrinter*) printjob->printer)->printjob = NULL; free(cups_printjob) ; } static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id) { - rdpCupsPrinter* cups_printer = (rdpCupsPrinter*)printer; + rdpCupsPrinter* cups_printer = (rdpCupsPrinter*) printer; rdpCupsPrintJob* cups_printjob; if (cups_printer->printjob != NULL) return NULL; - cups_printjob = xnew(rdpCupsPrintJob); + cups_printjob = (rdpCupsPrintJob*) malloc(sizeof(rdpCupsPrintJob)); + ZeroMemory(cups_printjob, sizeof(rdpCupsPrintJob)); cups_printjob->printjob.id = id; cups_printjob->printjob.printer = printer; @@ -161,6 +167,7 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id) char buf[100]; cups_printjob->printjob_object = httpConnectEncrypt(cupsServer(), ippPort(), HTTP_ENCRYPT_IF_REQUESTED); + if (cups_printjob->printjob_object == NULL) { DEBUG_WARN("httpConnectEncrypt: %s", cupsLastErrorString()); @@ -169,19 +176,19 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id) } printer_cups_get_printjob_name(buf, sizeof(buf)); - cups_printjob->printjob_id = cupsCreateJob((http_t*)cups_printjob->printjob_object, + cups_printjob->printjob_id = cupsCreateJob((http_t*) cups_printjob->printjob_object, printer->name, buf, 0, NULL); if (cups_printjob->printjob_id == 0) { DEBUG_WARN("cupsCreateJob: %s", cupsLastErrorString()); - httpClose((http_t*)cups_printjob->printjob_object); + httpClose((http_t*) cups_printjob->printjob_object); free(cups_printjob); return NULL; } - cupsStartDocument((http_t*)cups_printjob->printjob_object, - printer->name, cups_printjob->printjob_id, buf, - CUPS_FORMAT_AUTO, 1); + + cupsStartDocument((http_t*) cups_printjob->printjob_object, + printer->name, cups_printjob->printjob_id, buf, CUPS_FORMAT_AUTO, 1); } #endif @@ -205,10 +212,11 @@ static rdpPrintJob* printer_cups_find_printjob(rdpPrinter* printer, UINT32 id) static void printer_cups_free_printer(rdpPrinter* printer) { - rdpCupsPrinter* cups_printer = (rdpCupsPrinter*)printer; + rdpCupsPrinter* cups_printer = (rdpCupsPrinter*) printer; if (cups_printer->printjob) - cups_printer->printjob->printjob.Close((rdpPrintJob*)cups_printer->printjob); + cups_printer->printjob->printjob.Close((rdpPrintJob*) cups_printer->printjob); + free(printer->name); free(printer); } @@ -217,7 +225,8 @@ static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver, c { rdpCupsPrinter* cups_printer; - cups_printer = xnew(rdpCupsPrinter); + cups_printer = (rdpCupsPrinter*) malloc(sizeof(rdpCupsPrinter)); + ZeroMemory(cups_printer, sizeof(rdpCupsPrinter)); cups_printer->printer.id = cups_driver->id_sequence++; cups_printer->printer.name = _strdup(name); @@ -229,7 +238,7 @@ static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver, c cups_printer->printer.FindPrintJob = printer_cups_find_printjob; cups_printer->printer.Free = printer_cups_free_printer; - return (rdpPrinter*)cups_printer; + return (rdpPrinter*) cups_printer; } static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver) @@ -262,7 +271,7 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver) static rdpPrinter* printer_cups_get_printer(rdpPrinterDriver* driver, const char* name) { - rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*)driver; + rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*) driver; return printer_cups_new_printer(cups_driver, name, cups_driver->id_sequence == 1 ? TRUE : FALSE); } @@ -273,7 +282,8 @@ rdpPrinterDriver* printer_cups_get_driver(void) { if (cups_driver == NULL) { - cups_driver = xnew(rdpCupsPrinterDriver); + cups_driver = (rdpCupsPrinterDriver*) malloc(sizeof(rdpCupsPrinterDriver)); + ZeroMemory(cups_driver, sizeof(rdpCupsPrinterDriver)); cups_driver->driver.EnumPrinters = printer_cups_enum_printers; cups_driver->driver.GetPrinter = printer_cups_get_printer; @@ -287,6 +297,6 @@ rdpPrinterDriver* printer_cups_get_driver(void) #endif } - return (rdpPrinterDriver*)cups_driver; + return (rdpPrinterDriver*) cups_driver; } diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index 4ce760484cd8..675a1d582f57 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -247,7 +247,8 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri port = malloc(10); snprintf(port, 10, "PRN%d", printer->id); - printer_dev = xnew(PRINTER_DEVICE); + printer_dev = (PRINTER_DEVICE*) malloc(sizeof(PRINTER_DEVICE)); + ZeroMemory(printer_dev, sizeof(PRINTER_DEVICE)); printer_dev->device.type = RDPDR_DTYP_PRINT; printer_dev->device.name = port; diff --git a/channels/printer/client/printer_win.c b/channels/printer/client/printer_win.c index fc0a92335692..b2734eaa1608 100644 --- a/channels/printer/client/printer_win.c +++ b/channels/printer/client/printer_win.c @@ -121,7 +121,8 @@ static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, UINT32 id) if (win_printer->printjob != NULL) return NULL; - win_printjob = xnew(rdpWinPrintJob); + win_printjob = (rdpWinPrintJob*) malloc(sizeof(rdpWinPrintJob)); + ZeroMemory(win_printjob, sizeof(rdpWinPrintJob)); win_printjob->printjob.id = id; win_printjob->printjob.printer = printer; @@ -129,17 +130,17 @@ static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, UINT32 id) win_printjob->di.pDatatype= NULL; win_printjob->di.pOutputFile = NULL; - win_printjob->handle = StartDocPrinter(win_printer->hPrinter, 1, (LPBYTE)&(win_printjob->di) ); - if(! win_printjob->handle) DEBUG_WINPR("StartDocPrinter failed"); - if ( ! StartPagePrinter(win_printer->hPrinter) ) - DEBUG_WINPR("ClosePrinter failed"); + win_printjob->handle = StartDocPrinter(win_printer->hPrinter, 1, (LPBYTE) &(win_printjob->di)); + if (!win_printjob->handle) + DEBUG_WINPR("StartDocPrinter failed"); + + if (!StartPagePrinter(win_printer->hPrinter)) + DEBUG_WINPR("ClosePrinter failed"); win_printjob->printjob.Write = printer_win_write_printjob; win_printjob->printjob.Close = printer_win_close_printjob; - - win_printer->printjob = win_printjob; return (rdpPrintJob*) win_printjob; @@ -147,7 +148,7 @@ static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, UINT32 id) static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, UINT32 id) { - rdpWinPrinter* win_printer = (rdpWinPrinter*)printer; + rdpWinPrinter* win_printer = (rdpWinPrinter*) printer; DEBUG_WINPR(""); @@ -162,7 +163,7 @@ static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, UINT32 id) static void printer_win_free_printer(rdpPrinter* printer) { - rdpWinPrinter* win_printer = (rdpWinPrinter*)printer; + rdpWinPrinter* win_printer = (rdpWinPrinter*) printer; DEBUG_WINPR(""); @@ -182,7 +183,8 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, cons size_t charsConverted; DEBUG_WINPR(""); - win_printer = xnew(rdpWinPrinter); + win_printer = (rdpWinPrinter*) malloc(sizeof(rdpWinPrinter)); + ZeroMemory(win_printer, sizeof(rdpWinPrinter)); win_printer->printer.id = win_driver->id_sequence++; win_printer->printer.name = _strdup(name); @@ -269,20 +271,15 @@ rdpPrinterDriver* printer_win_get_driver(void) if (win_driver == NULL) { - win_driver = xnew(rdpWinPrinterDriver); + win_driver = (rdpWinPrinterDriver*) malloc(sizeof(rdpWinPrinterDriver)); + ZeroMemory(win_driver, sizeof(rdpWinPrinterDriver)); win_driver->driver.EnumPrinters = printer_win_enum_printers; win_driver->driver.GetPrinter = printer_win_get_printer; win_driver->id_sequence = 1; - -//#ifdef _win_API_1_4 -// DEBUG_SVC("using win API 1.4"); -//#else -// DEBUG_SVC("using win API 1.2"); -//#endif } - return (rdpPrinterDriver*)win_driver; + return (rdpPrinterDriver*) win_driver; } diff --git a/channels/rdpsnd/client/mac/rdpsnd_mac.c b/channels/rdpsnd/client/mac/rdpsnd_mac.c index 022e0adae251..cf92002d7ca8 100644 --- a/channels/rdpsnd/client/mac/rdpsnd_mac.c +++ b/channels/rdpsnd/client/mac/rdpsnd_mac.c @@ -29,6 +29,8 @@ #include #include +#include + #include #include #include @@ -206,7 +208,8 @@ int freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pE ADDIN_ARGV* args; rdpsndAudioQPlugin* aqPlugin; - aqPlugin = xnew(rdpsndAudioQPlugin); + aqPlugin = (rdpsndAudioQPlugin*) malloc(sizeof(rdpsndAudioQPlugin)); + ZeroMemory(aqPlugin, sizeof(rdpsndAudioQPlugin)); aqPlugin->device.Open = rdpsnd_audio_open; aqPlugin->device.FormatSupported = rdpsnd_audio_format_supported; diff --git a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c index 21365f3cac79..4a00c348cc99 100644 --- a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c +++ b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c @@ -570,7 +570,8 @@ int freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pE ADDIN_ARGV* args; rdpsndPulsePlugin* pulse; - pulse = xnew(rdpsndPulsePlugin); + pulse = (rdpsndPulsePlugin*) malloc(sizeof(rdpsndPulsePlugin)); + ZeroMemory(pulse, sizeof(rdpsndPulsePlugin)); pulse->device.Open = rdpsnd_pulse_open; pulse->device.FormatSupported = rdpsnd_pulse_format_supported; diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index e77811920ec7..f83604e6e39d 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -363,7 +363,9 @@ static void rdpsnd_process_message_wave(rdpsndPlugin* rdpsnd, STREAM* data_in) DEBUG_SVC("data_size %d delay_ms %u process_ms %u", stream_get_size(data_in), delay_ms, process_ms); - item = xnew(struct data_out_item); + item = (struct data_out_item*) malloc(sizeof(struct data_out_item)); + ZeroMemory(item, sizeof(struct data_out_item)); + item->data_out = stream_new(8); stream_write_BYTE(item->data_out, SNDC_WAVECONFIRM); stream_write_BYTE(item->data_out, 0); diff --git a/channels/rdpsnd/server/rdpsnd.c b/channels/rdpsnd/server/rdpsnd.c index b56753e0e6b3..933402b2a33e 100644 --- a/channels/rdpsnd/server/rdpsnd.c +++ b/channels/rdpsnd/server/rdpsnd.c @@ -109,6 +109,8 @@ static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, STREAM* s) } RDPSND_PDU_FINISH(s); + + return TRUE; } static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, STREAM* s) @@ -451,7 +453,9 @@ rdpsnd_server_context* rdpsnd_server_context_new(WTSVirtualChannelManager* vcm) { rdpsnd_server* rdpsnd; - rdpsnd = xnew(rdpsnd_server); + rdpsnd = (rdpsnd_server*) malloc(sizeof(rdpsnd_server)); + ZeroMemory(rdpsnd, sizeof(rdpsnd_server)); + rdpsnd->context.vcm = vcm; rdpsnd->context.selected_client_format = -1; rdpsnd->context.Initialize = rdpsnd_server_initialize; diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 3977eb05c185..a76e8b810b1e 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -708,7 +708,8 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) if (name[0] && path[0]) { - serial = xnew(SERIAL_DEVICE); + serial = (SERIAL_DEVICE*) malloc(sizeof(SERIAL_DEVICE)); + ZeroMemory(serial, sizeof(SERIAL_DEVICE)); serial->device.type = RDPDR_DTYP_SERIAL; serial->device.name = name; diff --git a/channels/server/channels.c b/channels/server/channels.c index 09105132cbf0..23b8f0b11511 100644 --- a/channels/server/channels.c +++ b/channels/server/channels.c @@ -30,6 +30,7 @@ #include #include +#include #include #include "channels.h" @@ -99,7 +100,9 @@ static void wts_queue_receive_data(rdpPeerChannel* channel, const BYTE* buffer, { wts_data_item* item; - item = xnew(wts_data_item); + item = (wts_data_item*) malloc(sizeof(wts_data_item)); + ZeroMemory(item, sizeof(wts_data_item)); + item->length = length; item->buffer = malloc(length); memcpy(item->buffer, buffer, length); @@ -411,10 +414,12 @@ WTSVirtualChannelManager* WTSCreateVirtualChannelManager(freerdp_peer* client) { WTSVirtualChannelManager* vcm; - vcm = xnew(WTSVirtualChannelManager); + vcm = (WTSVirtualChannelManager*) malloc(sizeof(WTSVirtualChannelManager)); if (vcm != NULL) { + ZeroMemory(vcm, sizeof(WTSVirtualChannelManager)); + vcm->client = client; vcm->send_event = wait_obj_new(); vcm->send_queue = list_new(); @@ -535,7 +540,9 @@ void* WTSVirtualChannelOpenEx( return NULL; } - channel = xnew(rdpPeerChannel); + channel = (rdpPeerChannel*) malloc(sizeof(rdpPeerChannel)); + ZeroMemory(channel, sizeof(rdpPeerChannel)); + channel->vcm = vcm; channel->client = client; channel->channel_type = RDP_PEER_CHANNEL_TYPE_DVC; @@ -579,7 +586,9 @@ void* WTSVirtualChannelOpenEx( if (channel == NULL) { - channel = xnew(rdpPeerChannel); + channel = (rdpPeerChannel*) malloc(sizeof(rdpPeerChannel)); + ZeroMemory(channel, sizeof(rdpPeerChannel)); + channel->vcm = vcm; channel->client = client; channel->channel_id = client->settings->ChannelDefArray[i].ChannelId; @@ -718,7 +727,9 @@ BOOL WTSVirtualChannelWrite( if (channel->channel_type == RDP_PEER_CHANNEL_TYPE_SVC) { - item = xnew(wts_data_item); + item = (wts_data_item*) malloc(sizeof(wts_data_item)); + ZeroMemory(item, sizeof(wts_data_item)); + item->buffer = malloc(Length); item->length = Length; memcpy(item->buffer, Buffer, Length); @@ -737,7 +748,9 @@ BOOL WTSVirtualChannelWrite( while (Length > 0) { - item = xnew(wts_data_item); + item = (wts_data_item*) malloc(sizeof(wts_data_item)); + ZeroMemory(item, sizeof(wts_data_item)); + item->buffer = malloc(channel->client->settings->VirtualChannelChunkSize); stream_attach(s, item->buffer, channel->client->settings->VirtualChannelChunkSize); diff --git a/client/DirectFB/df_graphics.c b/client/DirectFB/df_graphics.c index 8d138fea5f95..6c74c92ab9e4 100644 --- a/client/DirectFB/df_graphics.c +++ b/client/DirectFB/df_graphics.c @@ -17,6 +17,8 @@ * limitations under the License. */ +#include + #include #include "df_graphics.h" @@ -123,7 +125,8 @@ void df_register_graphics(rdpGraphics* graphics) { rdpPointer* pointer; - pointer = xnew(rdpPointer); + pointer = (rdpPointer*) malloc(sizeof(rdpPointer)); + ZeroMemory(pointer, sizeof(rdpPointer)); pointer->size = sizeof(dfPointer); pointer->New = df_Pointer_New; diff --git a/client/DirectFB/dfreerdp.c b/client/DirectFB/dfreerdp.c index e3037267b7d0..e01c35ef3e15 100644 --- a/client/DirectFB/dfreerdp.c +++ b/client/DirectFB/dfreerdp.c @@ -155,11 +155,15 @@ BOOL df_pre_connect(freerdp* instance) settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE; settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE; - dfi->clrconv = xnew(CLRCONV); + dfi->clrconv = (CLRCONV*) malloc(sizeof(CLRCONV)); + ZeroMemory(dfi->clrconv, sizeof(CLRCONV)); + dfi->clrconv->alpha = 1; dfi->clrconv->invert = 0; dfi->clrconv->rgb555 = 0; - dfi->clrconv->palette = xnew(rdpPalette); + + dfi->clrconv->palette = (rdpPalette*) malloc(sizeof(rdpPalette)); + ZeroMemory(dfi->clrconv->palette, sizeof(rdpPalette)); freerdp_channels_pre_connect(instance->context->channels, instance); diff --git a/cunit/test_rfx.c b/cunit/test_rfx.c index f42ead9861c3..c8bc40ff7ec1 100644 --- a/cunit/test_rfx.c +++ b/cunit/test_rfx.c @@ -25,11 +25,15 @@ #include #include #include + +#include + #include #include #include #include #include + #include "rfx_types.h" #include "rfx_bitstream.h" #include "rfx_rlgr.h" @@ -191,8 +195,11 @@ void test_bitstream(void) UINT16 b; RFX_BITSTREAM* bs; - bs = xnew(RFX_BITSTREAM); + bs = (RFX_BITSTREAM*) malloc(sizeof(RFX_BITSTREAM)); + ZeroMemory(bs, sizeof(RFX_BITSTREAM)); + rfx_bitstream_attach(bs, (BYTE*) y_data, sizeof(y_data)); + while (!rfx_bitstream_eos(bs)) { rfx_bitstream_get_bits(bs, 3, b); @@ -210,7 +217,9 @@ void test_bitstream_enc(void) RFX_BITSTREAM* bs; int i; - bs = xnew(RFX_BITSTREAM); + bs = (RFX_BITSTREAM*) malloc(sizeof(RFX_BITSTREAM)); + ZeroMemory(bs, sizeof(RFX_BITSTREAM)); + memset(buffer, 0, sizeof(buffer)); rfx_bitstream_attach(bs, buffer, sizeof(buffer)); for (i = 0; i < 16; i++) diff --git a/include/freerdp/utils/memory.h b/include/freerdp/utils/memory.h index 27f08e75f9b0..06a751680ce2 100644 --- a/include/freerdp/utils/memory.h +++ b/include/freerdp/utils/memory.h @@ -26,10 +26,6 @@ #include -FREERDP_API void* xzalloc(size_t size); - -#define xnew(_type) (_type*)xzalloc(sizeof(_type)) - #define ARRAY_SIZE(_x) (sizeof(_x)/sizeof(*(_x))) #endif /* __MEMORY_UTILS_H */ diff --git a/include/freerdp/utils/svc_plugin.h b/include/freerdp/utils/svc_plugin.h index 2748853db37e..623e70b7617d 100644 --- a/include/freerdp/utils/svc_plugin.h +++ b/include/freerdp/utils/svc_plugin.h @@ -26,6 +26,7 @@ #include #include #include + #include #include #include @@ -59,37 +60,4 @@ FREERDP_API int svc_plugin_send_event(rdpSvcPlugin* plugin, RDP_EVENT* event); #define DEBUG_SVC(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__) #endif -#ifdef STATIC_CHANNELS -#define DEFINE_SVC_PLUGIN_ENTRY(_prefix) int _prefix##_entry(PCHANNEL_ENTRY_POINTS pEntryPoints) -#define DEFINE_DEV_PLUGIN_ENTRY(_prefix) int _prefix##_entry(PCHANNEL_ENTRY_POINTS pEntryPoints) -#define REGISTER_SVC_PLUGIN_ENTRY(_prefix) freerdp_register_static_plugin(#_prefix, "VirtualChannelEntry", _prefix##_entry) -#define REGISTER_DEV_PLUGIN_ENTRY(_prefix) freerdp_register_static_plugin(#_prefix, "DeviceServiceEntry", _prefix##_entry) -#else -#define REGISTER_DEV_PLUGIN_ENTRY(_prefix) -#define REGISTER_SVC_PLUGIN_ENTRY(_prefix) -#define DEFINE_DEV_PLUGIN_ENTRY(_prefix) -#define DEFINE_SVC_PLUGIN_ENTRY(_prefix) int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) -#endif - -#define DEFINE_SVC_PLUGIN(_prefix, _name, _options) \ -\ -DEFINE_SVC_PLUGIN_ENTRY(_prefix) \ -{ \ - _prefix##Plugin* _p; \ -\ - _p = xnew(_prefix##Plugin); \ -\ - _p->plugin.channel_def.options = _options; \ - strcpy(_p->plugin.channel_def.name, _name); \ -\ - _p->plugin.connect_callback = _prefix##_process_connect; \ - _p->plugin.receive_callback = _prefix##_process_receive; \ - _p->plugin.event_callback = _prefix##_process_event; \ - _p->plugin.terminate_callback = _prefix##_process_terminate; \ -\ - svc_plugin_init((rdpSvcPlugin*)_p, pEntryPoints); \ -\ - return 1; \ -} - #endif /* __SVC_PLUGIN_UTILS_H */ diff --git a/libfreerdp/codec/color.c b/libfreerdp/codec/color.c index cf65680b6ce9..45c910e4b0b2 100644 --- a/libfreerdp/codec/color.c +++ b/libfreerdp/codec/color.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -1076,12 +1078,17 @@ void freerdp_image_swap_color_order(BYTE* data, int width, int height) HCLRCONV freerdp_clrconv_new(UINT32 flags) { - HCLRCONV clrconv = xnew(CLRCONV); + HCLRCONV clrconv; + + clrconv = (CLRCONV*) malloc(sizeof(CLRCONV)); + ZeroMemory(clrconv, sizeof(CLRCONV)); clrconv->alpha = (flags & CLRCONV_ALPHA) ? TRUE : FALSE; clrconv->invert = (flags & CLRCONV_INVERT) ? TRUE : FALSE; clrconv->rgb555 = (flags & CLRCONV_RGB555) ? TRUE : FALSE; - clrconv->palette = xnew(rdpPalette); + + clrconv->palette = (rdpPalette*) malloc(sizeof(rdpPalette)); + ZeroMemory(clrconv->palette, sizeof(rdpPalette)); return clrconv; } diff --git a/libfreerdp/codec/mppc_enc.c b/libfreerdp/codec/mppc_enc.c index 91a748227e74..15851d70acdc 100644 --- a/libfreerdp/codec/mppc_enc.c +++ b/libfreerdp/codec/mppc_enc.c @@ -432,19 +432,24 @@ struct rdp_mppc_enc* mppc_enc_new(int protocol_type) { struct rdp_mppc_enc* enc; - enc = xnew(struct rdp_mppc_enc); + enc = (struct rdp_mppc_enc*) malloc(sizeof(struct rdp_mppc_enc)); + ZeroMemory(enc, sizeof(struct rdp_mppc_enc)); + if (enc == NULL) return NULL; + switch (protocol_type) { case PROTO_RDP_40: enc->protocol_type = PROTO_RDP_40; enc->buf_len = RDP_40_HIST_BUF_LEN; break; + case PROTO_RDP_50: enc->protocol_type = PROTO_RDP_50; enc->buf_len = RDP_50_HIST_BUF_LEN; break; + default: free(enc); return NULL; @@ -515,15 +520,18 @@ BOOL compress_rdp(struct rdp_mppc_enc* enc, BYTE* srcData, int len) { if ((enc == NULL) || (srcData == NULL) || (len <= 0) || (len > enc->buf_len)) return FALSE; + switch (enc->protocol_type) { case PROTO_RDP_40: return compress_rdp_4(enc, srcData, len); break; + case PROTO_RDP_50: return compress_rdp_5(enc, srcData, len); break; } + return FALSE; } diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index 777d296ba6b1..9a8b699cc9f7 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -267,8 +267,8 @@ NSC_CONTEXT* nsc_context_new(void) { NSC_CONTEXT* nsc_context; - nsc_context = xnew(NSC_CONTEXT); - nsc_context->priv = xnew(NSC_CONTEXT_PRIV); + nsc_context = (NSC_CONTEXT*) malloc(sizeof(NSC_CONTEXT)); + nsc_context->priv = (NSC_CONTEXT_PRIV*) malloc(sizeof(NSC_CONTEXT_PRIV)); nsc_context->decode = nsc_decode; nsc_context->encode = nsc_encode; diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index a1d4af3350f4..c203756ed608 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -24,10 +24,13 @@ #include #include #include + #ifdef HAVE_STDINT_H #include #endif +#include + #include #include #include @@ -140,8 +143,12 @@ RFX_CONTEXT* rfx_context_new(void) { RFX_CONTEXT* context; - context = xnew(RFX_CONTEXT); - context->priv = xnew(RFX_CONTEXT_PRIV); + context = (RFX_CONTEXT*) malloc(sizeof(RFX_CONTEXT)); + ZeroMemory(context, sizeof(RFX_CONTEXT)); + + context->priv = (RFX_CONTEXT_PRIV*) malloc(sizeof(RFX_CONTEXT_PRIV)); + ZeroMemory(context->priv, sizeof(RFX_CONTEXT_PRIV)); + context->priv->pool = rfx_pool_new(); /* initialize the default pixel format */ @@ -517,8 +524,10 @@ RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length UINT32 blockType; RFX_MESSAGE* message; + message = (RFX_MESSAGE*) malloc(sizeof(RFX_MESSAGE)); + ZeroMemory(message, sizeof(RFX_MESSAGE)); + s = stream_new(0); - message = xnew(RFX_MESSAGE); stream_attach(s, data, length); while (stream_get_left(s) > 6) diff --git a/libfreerdp/codec/rfx_rlgr.c b/libfreerdp/codec/rfx_rlgr.c index c2ef387652bf..38163f9e516e 100644 --- a/libfreerdp/codec/rfx_rlgr.c +++ b/libfreerdp/codec/rfx_rlgr.c @@ -30,6 +30,8 @@ #include #include +#include + #include #include "rfx_bitstream.h" @@ -134,7 +136,9 @@ int rfx_rlgr_decode(RLGR_MODE mode, const BYTE* data, int data_size, INT16* buff int vk; UINT16 mag16; - bs = xnew(RFX_BITSTREAM); + bs = (RFX_BITSTREAM*) malloc(sizeof(RFX_BITSTREAM)); + ZeroMemory(bs, sizeof(RFX_BITSTREAM)); + rfx_bitstream_attach(bs, data, data_size); dst = buffer; @@ -306,7 +310,9 @@ int rfx_rlgr_encode(RLGR_MODE mode, const INT16* data, int data_size, BYTE* buff RFX_BITSTREAM* bs; int processed_size; - bs = xnew(RFX_BITSTREAM); + bs = (RFX_BITSTREAM*) malloc(sizeof(RFX_BITSTREAM)); + ZeroMemory(bs, sizeof(RFX_BITSTREAM)); + rfx_bitstream_attach(bs, buffer, buffer_size); /* initialize the parameters */ diff --git a/libfreerdp/core/extension.c b/libfreerdp/core/extension.c index 293b845d5d9b..608329b8c136 100644 --- a/libfreerdp/core/extension.c +++ b/libfreerdp/core/extension.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -211,7 +213,8 @@ rdpExtension* extension_new(freerdp* instance) if (instance != NULL) { - extension = xnew(rdpExtension); + extension = (rdpExtension*) malloc(sizeof(rdpExtension)); + ZeroMemory(extension, sizeof(rdpExtension)); extension->instance = instance; } diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index eaeca8509f65..22de4520357f 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -764,7 +766,9 @@ rdpFastPath* fastpath_new(rdpRdp* rdp) { rdpFastPath* fastpath; - fastpath = xnew(rdpFastPath); + fastpath = (rdpFastPath*) malloc(sizeof(rdpFastPath)); + ZeroMemory(fastpath, sizeof(rdpFastPath)); + fastpath->rdp = rdp; fastpath->updateData = stream_new(4096); diff --git a/libfreerdp/core/http.c b/libfreerdp/core/http.c index 9ac9e5272c83..76f1eaa4dcd6 100644 --- a/libfreerdp/core/http.c +++ b/libfreerdp/core/http.c @@ -30,11 +30,11 @@ HttpContext* http_context_new() { - HttpContext* http_context = xnew(HttpContext); + HttpContext* http_context = (HttpContext*) malloc(sizeof(HttpContext)); if (http_context != NULL) { - + ZeroMemory(http_context, sizeof(HttpContext)); } return http_context; @@ -255,11 +255,11 @@ STREAM* http_request_write(HttpContext* http_context, HttpRequest* http_request) HttpRequest* http_request_new() { - HttpRequest* http_request = xnew(HttpRequest); + HttpRequest* http_request = (HttpRequest*) malloc(sizeof(HttpRequest)); if (http_request != NULL) { - + ZeroMemory(http_request, sizeof(HttpRequest)); } return http_request; @@ -496,11 +496,13 @@ HttpResponse* http_response_recv(rdpTls* tls) HttpResponse* http_response_new() { - HttpResponse* http_response = xnew(HttpResponse); + HttpResponse* http_response; + + http_response = (HttpResponse*) malloc(sizeof(HttpResponse)); if (http_response != NULL) { - + ZeroMemory(http_response, sizeof(HttpResponse)); } return http_response; diff --git a/libfreerdp/core/listener.c b/libfreerdp/core/listener.c index a124a369b10b..f89217920798 100644 --- a/libfreerdp/core/listener.c +++ b/libfreerdp/core/listener.c @@ -26,6 +26,8 @@ #include #include +#include + #include #ifndef _WIN32 @@ -312,14 +314,18 @@ freerdp_listener* freerdp_listener_new(void) freerdp_listener* instance; rdpListener* listener; - instance = xnew(freerdp_listener); + instance = (freerdp_listener*) malloc(sizeof(freerdp_listener)); + ZeroMemory(instance, sizeof(freerdp_listener)); + instance->Open = freerdp_listener_open; instance->OpenLocal = freerdp_listener_open_local; instance->GetFileDescriptor = freerdp_listener_get_fds; instance->CheckFileDescriptor = freerdp_listener_check_fds; instance->Close = freerdp_listener_close; - listener = xnew(rdpListener); + listener = (rdpListener*) malloc(sizeof(rdpListener)); + ZeroMemory(listener, sizeof(rdpListener)); + listener->instance = instance; instance->listener = (void*) listener; diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index 90e133046157..c0371c546795 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -396,7 +396,8 @@ freerdp_peer* freerdp_peer_new(int sockfd) { freerdp_peer* client; - client = xnew(freerdp_peer); + client = (freerdp_peer*) malloc(sizeof(freerdp_peer)); + ZeroMemory(client, sizeof(freerdp_peer)); freerdp_tcp_set_no_delay(sockfd, TRUE); diff --git a/libfreerdp/gdi/graphics.c b/libfreerdp/gdi/graphics.c index f49b4e70bf84..3fba1bda6dbb 100644 --- a/libfreerdp/gdi/graphics.c +++ b/libfreerdp/gdi/graphics.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include #include @@ -264,7 +266,8 @@ void gdi_register_graphics(rdpGraphics* graphics) rdpBitmap* bitmap; rdpGlyph* glyph; - bitmap = xnew(rdpBitmap); + bitmap = (rdpBitmap*) malloc(sizeof(rdpBitmap)); + ZeroMemory(bitmap, sizeof(rdpBitmap)); bitmap->size = sizeof(gdiBitmap); bitmap->New = gdi_Bitmap_New; @@ -276,7 +279,8 @@ void gdi_register_graphics(rdpGraphics* graphics) graphics_register_bitmap(graphics, bitmap); free(bitmap); - glyph = xnew(rdpGlyph); + glyph = (rdpGlyph*) malloc(sizeof(rdpGlyph)); + ZeroMemory(glyph, sizeof(rdpGlyph)); glyph->size = sizeof(gdiGlyph); glyph->New = gdi_Glyph_New; diff --git a/libfreerdp/utils/dsp.c b/libfreerdp/utils/dsp.c index 189efc5106cc..afcbe88c48e4 100644 --- a/libfreerdp/utils/dsp.c +++ b/libfreerdp/utils/dsp.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -595,7 +597,8 @@ FREERDP_DSP_CONTEXT* freerdp_dsp_context_new(void) { FREERDP_DSP_CONTEXT* context; - context = xnew(FREERDP_DSP_CONTEXT); + context = (FREERDP_DSP_CONTEXT*) malloc(sizeof(FREERDP_DSP_CONTEXT)); + ZeroMemory(context, sizeof(FREERDP_DSP_CONTEXT)); context->resample = freerdp_dsp_resample; context->decode_ima_adpcm = freerdp_dsp_decode_ima_adpcm; diff --git a/libfreerdp/utils/event.c b/libfreerdp/utils/event.c index 48ee7109b2ee..370d56d83324 100644 --- a/libfreerdp/utils/event.c +++ b/libfreerdp/utils/event.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -38,16 +40,23 @@ static RDP_EVENT* freerdp_cliprdr_event_new(UINT16 event_type) switch (event_type) { case RDP_EVENT_TYPE_CB_MONITOR_READY: - event = (RDP_EVENT*) xnew(RDP_CB_MONITOR_READY_EVENT); + event = (RDP_EVENT*) malloc(sizeof(RDP_CB_MONITOR_READY_EVENT)); + ZeroMemory(event, sizeof(RDP_CB_MONITOR_READY_EVENT)); break; + case RDP_EVENT_TYPE_CB_FORMAT_LIST: - event = (RDP_EVENT*) xnew(RDP_CB_FORMAT_LIST_EVENT); + event = (RDP_EVENT*) malloc(sizeof(RDP_CB_FORMAT_LIST_EVENT)); + ZeroMemory(event, sizeof(RDP_CB_FORMAT_LIST_EVENT)); break; + case RDP_EVENT_TYPE_CB_DATA_REQUEST: - event = (RDP_EVENT*) xnew(RDP_CB_DATA_REQUEST_EVENT); + event = (RDP_EVENT*) malloc(sizeof(RDP_CB_DATA_REQUEST_EVENT)); + ZeroMemory(event, sizeof(RDP_CB_DATA_REQUEST_EVENT)); break; + case RDP_EVENT_TYPE_CB_DATA_RESPONSE: - event = (RDP_EVENT*) xnew(RDP_CB_DATA_RESPONSE_EVENT); + event = (RDP_EVENT*) malloc(sizeof(RDP_CB_DATA_RESPONSE_EVENT)); + ZeroMemory(event, sizeof(RDP_CB_DATA_RESPONSE_EVENT)); break; } @@ -61,10 +70,13 @@ static RDP_EVENT* freerdp_tsmf_event_new(UINT16 event_type) switch (event_type) { case RDP_EVENT_TYPE_TSMF_VIDEO_FRAME: - event = (RDP_EVENT*) xnew(RDP_VIDEO_FRAME_EVENT); + event = (RDP_EVENT*) malloc(sizeof(RDP_VIDEO_FRAME_EVENT)); + ZeroMemory(event, sizeof(RDP_VIDEO_FRAME_EVENT)); break; + case RDP_EVENT_TYPE_TSMF_REDRAW: - event = (RDP_EVENT*) xnew(RDP_REDRAW_EVENT); + event = (RDP_EVENT*) malloc(sizeof(RDP_REDRAW_EVENT)); + ZeroMemory(event, sizeof(RDP_REDRAW_EVENT)); break; } @@ -74,7 +86,10 @@ static RDP_EVENT* freerdp_tsmf_event_new(UINT16 event_type) static RDP_EVENT* freerdp_rail_event_new(UINT16 event_type) { RDP_EVENT* event = NULL; - event = xnew(RDP_EVENT); + + event = (RDP_EVENT*) malloc(sizeof(RDP_EVENT)); + ZeroMemory(event, sizeof(RDP_EVENT)); + return event; } @@ -86,14 +101,18 @@ RDP_EVENT* freerdp_event_new(UINT16 event_class, UINT16 event_type, switch (event_class) { case RDP_EVENT_CLASS_DEBUG: - event = xnew(RDP_EVENT); + event = (RDP_EVENT*) malloc(sizeof(RDP_EVENT)); + ZeroMemory(event, sizeof(RDP_EVENT)); break; + case RDP_EVENT_CLASS_CLIPRDR: event = freerdp_cliprdr_event_new(event_type); break; + case RDP_EVENT_CLASS_TSMF: event = freerdp_tsmf_event_new(event_type); break; + case RDP_EVENT_CLASS_RAIL: event = freerdp_rail_event_new(event_type); break; diff --git a/libfreerdp/utils/list.c b/libfreerdp/utils/list.c index 89cb1f41d283..87b9a590f72c 100644 --- a/libfreerdp/utils/list.c +++ b/libfreerdp/utils/list.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include @@ -40,9 +42,12 @@ static LIST_ITEM* list_item_new(void* data) { LIST_ITEM* item; - item = xnew(LIST_ITEM); + item = (LIST_ITEM*) malloc(sizeof(LIST_ITEM)); + ZeroMemory(item, sizeof(LIST_ITEM)); + if (item) item->data = data; + return item; } @@ -83,8 +88,11 @@ LIST* list_new(void) { LIST* list; - list = xnew(LIST); + list = (LIST*) malloc(sizeof(LIST)); + ZeroMemory(list, sizeof(LIST)); + list->count = 0; + return list; } @@ -98,6 +106,7 @@ void list_free(LIST* list) { while (list->head) list_dequeue(list); + free(list); } @@ -112,6 +121,7 @@ void list_enqueue(LIST* list, void* data) LIST_ITEM* item; item = list_item_new(data); + if (list->tail == NULL) { list->head = item; @@ -123,6 +133,7 @@ void list_enqueue(LIST* list, void* data) list->tail->next = item; list->tail = item; } + list->count++; } @@ -140,9 +151,11 @@ void* list_dequeue(LIST* list) void* data = NULL; item = list->head; + if (item != NULL) { list->head = item->next; + if (list->head == NULL) list->tail = NULL; else @@ -152,6 +165,7 @@ void* list_dequeue(LIST* list) free(item); list->count--; } + return data; } @@ -189,11 +203,13 @@ void* list_next(LIST* list, void* data) item = list_item_find(list, data); data = NULL; + if (item != NULL) { if (item->next != NULL) data = item->next->data; } + return data; } @@ -211,6 +227,7 @@ void* list_remove(LIST* list, void* data) LIST_ITEM* item; item = list_item_find(list, data); + if (item != NULL) { if (item->prev != NULL) @@ -225,7 +242,10 @@ void* list_remove(LIST* list, void* data) list->count--; } else + { data = NULL; + } + return data; } diff --git a/libfreerdp/utils/memory.c b/libfreerdp/utils/memory.c index eaa96dc28e42..76e6cfb6b576 100644 --- a/libfreerdp/utils/memory.c +++ b/libfreerdp/utils/memory.c @@ -27,32 +27,3 @@ #include -#include - -/** - * Allocate memory initialized to zero. - * This function is used to secure a calloc call. - * It verifies its return value, and logs an error if the allocation failed. - * - * @param size - number of bytes to allocate. If the size is < 1, it will default to 1. - * - * @return a pointer to the allocated and zeroed buffer. NULL if the allocation failed. - */ -void* xzalloc(size_t size) -{ - void* mem; - - if (size < 1) - size = 1; - - mem = calloc(1, size); - - if (mem == NULL) - { - perror("xzalloc"); - printf("xzalloc: failed to allocate memory of size: %d\n", (int) size); - } - - return mem; -} - diff --git a/libfreerdp/utils/stream.c b/libfreerdp/utils/stream.c index 9221d06e812c..8f13112ecd48 100644 --- a/libfreerdp/utils/stream.c +++ b/libfreerdp/utils/stream.c @@ -51,7 +51,8 @@ STREAM* stream_new(int size) { STREAM* stream; - stream = xnew(STREAM); + stream = malloc(sizeof(STREAM)); + ZeroMemory(stream, sizeof(STREAM)); if (stream != NULL) { diff --git a/libfreerdp/utils/svc_plugin.c b/libfreerdp/utils/svc_plugin.c index 2f232b230264..84703b0b41d6 100644 --- a/libfreerdp/utils/svc_plugin.c +++ b/libfreerdp/utils/svc_plugin.c @@ -196,7 +196,9 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT3 plugin->priv->data_in = NULL; stream_set_pos(data_in, 0); - item = xnew(svc_data_in_item); + item = (svc_data_in_item*) malloc(sizeof(svc_data_in_item)); + ZeroMemory(item, sizeof(svc_data_in_item)); + item->data_in = data_in; freerdp_thread_lock(plugin->priv->thread); diff --git a/libfreerdp/utils/thread.c b/libfreerdp/utils/thread.c index 98be69148580..6b14c9b74bfd 100644 --- a/libfreerdp/utils/thread.c +++ b/libfreerdp/utils/thread.c @@ -26,6 +26,7 @@ #include #include +#include #include #ifdef _WIN32 @@ -42,7 +43,9 @@ freerdp_thread* freerdp_thread_new(void) { freerdp_thread* thread; - thread = xnew(freerdp_thread); + thread = (freerdp_thread*) malloc(sizeof(freerdp_thread)); + ZeroMemory(thread, sizeof(freerdp_thread)); + thread->mutex = CreateMutex(NULL, FALSE, NULL); thread->signals[0] = wait_obj_new(); thread->signals[1] = wait_obj_new(); diff --git a/libfreerdp/utils/wait_obj.c b/libfreerdp/utils/wait_obj.c index 852abcf24305..552f0e3a624f 100644 --- a/libfreerdp/utils/wait_obj.c +++ b/libfreerdp/utils/wait_obj.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -52,7 +53,8 @@ struct wait_obj* wait_obj_new(void) { struct wait_obj* obj; - obj = xnew(struct wait_obj); + obj = (struct wait_obj*) malloc(sizeof(struct wait_obj)); + ZeroMemory(obj, sizeof(struct wait_obj)); obj->attached = 0; #ifdef _WIN32 @@ -76,7 +78,8 @@ struct wait_obj* wait_obj_new_with_fd(void* fd) { struct wait_obj* obj; - obj = xnew(struct wait_obj); + obj = (struct wait_obj*) malloc(sizeof(struct wait_obj)); + ZeroMemory(obj, sizeof(struct wait_obj)); obj->attached = 1; #ifdef _WIN32 @@ -93,7 +96,6 @@ void wait_obj_free(struct wait_obj* obj) { if (obj) { - if (obj->attached == 0) { #ifdef _WIN32 @@ -146,7 +148,9 @@ void wait_obj_set(struct wait_obj* obj) if (wait_obj_is_set(obj)) return; + len = write(obj->pipe_fd[1], "sig", 4); + if (len != 4) printf("wait_obj_set: error\n"); #endif diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index ef6374b627a2..f94a0edafd8c 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -32,6 +32,8 @@ #include #include +#include + #include #include #include @@ -177,7 +179,8 @@ xfInfo* xf_info_init() XPixmapFormatValues* pf; XPixmapFormatValues* pfs; - xfi = xnew(xfInfo); + xfi = (xfInfo*) malloc(sizeof(xfInfo)); + ZeroMemory(xfi, sizeof(xfInfo)); //xfi->use_xshm = TRUE; xfi->display = XOpenDisplay(NULL);