Merge branch 'master' of github.com:FreeRDP/FreeRDP-1.0

This commit is contained in:
Marc-André Moreau 2011-07-13 11:40:30 -04:00
commit 5659f3b901
13 changed files with 37 additions and 56 deletions

View File

@ -61,7 +61,7 @@ set(FREERDP_KEYMAP_PATH "${CMAKE_INSTALL_PREFIX}/freerdp/keymaps")
set(FREERDP_PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/lib/freerdp")
# Include directories
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
# Configure files

View File

@ -26,4 +26,4 @@ set_target_properties(rdpdbg PROPERTIES PREFIX "")
target_link_libraries(rdpdbg freerdp-utils)
install(TARGETS rdpdbg DESTINATION lib/freerdp)
install(TARGETS rdpdbg DESTINATION ${FREERDP_PLUGIN_PATH})

View File

@ -34,8 +34,7 @@ struct _item_type##_full \
static struct _item_type* _item_type##_new(void) \
{ \
struct _item_type* item; \
item = (struct _item_type*)xmalloc(sizeof(struct _item_type##_full));\
memset(item, 0, sizeof(struct _item_type##_full)); \
item = (struct _item_type*)xnew(struct _item_type##_full);\
return item; \
} \
\
@ -60,8 +59,7 @@ struct _list_type \
static struct _list_type* _list_type##_new(void) \
{ \
struct _list_type* list; \
list = (struct _list_type*)xmalloc(sizeof(struct _list_type)); \
memset(list, 0, sizeof(struct _list_type)); \
list = xnew(struct _list_type); \
return list; \
} \
\

View File

@ -24,8 +24,10 @@
void* xmalloc(size_t size);
void* xzalloc(size_t size);
void* xrealloc(void * ptr, size_t size);
void xfree(void * ptr);
char* xstrdup(const char * str);
void* xrealloc(void* ptr, size_t size);
void xfree(void* ptr);
char* xstrdup(const char* str);
#define xnew(_type) (_type*)xzalloc(sizeof(_type))
#endif /* __MEMORY_UTILS_H */

View File

@ -542,15 +542,14 @@ rdpChanMan* freerdp_chanman_new(void)
rdpChanMan* chan_man;
rdpChanManList* list;
chan_man = (rdpChanMan*)xmalloc(sizeof(rdpChanMan));
memset(chan_man, 0, sizeof(rdpChanMan));
chan_man = xnew(rdpChanMan);
chan_man->sync_data_sem = freerdp_sem_new(1);
chan_man->event_sem = freerdp_sem_new(1);
chan_man->signal = wait_obj_new();
/* Add it to the global list */
list = (rdpChanManList*)xmalloc(sizeof(rdpChanManList));
list = xnew(rdpChanManList);
list->chan_man = chan_man;
freerdp_mutex_lock(g_mutex_list);

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/event.h>
FRDP_EVENT* freerdp_event_new(uint32 event_type, FRDP_EVENT_CALLBACK on_event_free_callback, void* user_data)
@ -29,32 +30,25 @@ FRDP_EVENT* freerdp_event_new(uint32 event_type, FRDP_EVENT_CALLBACK on_event_fr
switch (event_type)
{
case FRDP_EVENT_TYPE_DEBUG:
event = (FRDP_EVENT*)xmalloc(sizeof(FRDP_EVENT));
memset(event, 0, sizeof(FRDP_EVENT));
event = xnew(FRDP_EVENT);
break;
case FRDP_EVENT_TYPE_VIDEO_FRAME:
event = (FRDP_EVENT*)xmalloc(sizeof(FRDP_VIDEO_FRAME_EVENT));
memset(event, 0, sizeof(FRDP_VIDEO_FRAME_EVENT));
event = (FRDP_EVENT*)xnew(FRDP_VIDEO_FRAME_EVENT);
break;
case FRDP_EVENT_TYPE_REDRAW:
event = (FRDP_EVENT*)xmalloc(sizeof(FRDP_REDRAW_EVENT));
memset(event, 0, sizeof(FRDP_REDRAW_EVENT));
event = (FRDP_EVENT*)xnew(FRDP_REDRAW_EVENT);
break;
case FRDP_EVENT_TYPE_CB_SYNC:
event = (FRDP_EVENT*)xmalloc(sizeof(FRDP_CB_SYNC_EVENT));
memset(event, 0, sizeof(FRDP_CB_SYNC_EVENT));
event = (FRDP_EVENT*)xnew(FRDP_CB_SYNC_EVENT);
break;
case FRDP_EVENT_TYPE_CB_FORMAT_LIST:
event = (FRDP_EVENT*)xmalloc(sizeof(FRDP_CB_FORMAT_LIST_EVENT));
memset(event, 0, sizeof(FRDP_CB_FORMAT_LIST_EVENT));
event = (FRDP_EVENT*)xnew(FRDP_CB_FORMAT_LIST_EVENT);
break;
case FRDP_EVENT_TYPE_CB_DATA_REQUEST:
event = (FRDP_EVENT*)xmalloc(sizeof(FRDP_CB_DATA_REQUEST_EVENT));
memset(event, 0, sizeof(FRDP_CB_DATA_REQUEST_EVENT));
event = (FRDP_EVENT*)xnew(FRDP_CB_DATA_REQUEST_EVENT);
break;
case FRDP_EVENT_TYPE_CB_DATA_RESPONSE:
event = (FRDP_EVENT*)xmalloc(sizeof(FRDP_CB_DATA_RESPONSE_EVENT));
memset(event, 0, sizeof(FRDP_CB_DATA_RESPONSE_EVENT));
event = (FRDP_EVENT*)xnew(FRDP_CB_DATA_RESPONSE_EVENT);
break;
}
if (event != NULL)

View File

@ -28,10 +28,9 @@
* @param size
*/
void *
xmalloc(size_t size)
void* xmalloc(size_t size)
{
void * mem;
void* mem;
if (size < 1)
size = 1;
@ -49,10 +48,9 @@ xmalloc(size_t size)
* @param size
*/
void *
xzalloc(size_t size)
void* xzalloc(size_t size)
{
void * mem;
void* mem;
if (size < 1)
size = 1;
@ -71,10 +69,9 @@ xzalloc(size_t size)
* @param size
*/
void *
xrealloc(void * ptr, size_t size)
void* xrealloc(void* ptr, size_t size)
{
void * mem;
void* mem;
if (size < 1)
size = 1;
@ -92,8 +89,7 @@ xrealloc(void * ptr, size_t size)
* @param mem
*/
void
xfree(void * ptr)
void xfree(void* ptr)
{
if (ptr != NULL)
free(ptr);
@ -105,10 +101,9 @@ xfree(void * ptr)
* @return
*/
char *
xstrdup(const char * str)
char* xstrdup(const char* str)
{
char * mem;
char* mem;
#ifdef _WIN32
mem = _strdup(str);

View File

@ -36,7 +36,7 @@ freerdp_mutex freerdp_mutex_new(void)
{
freerdp_mutex_t* mutex;
mutex = (freerdp_mutex_t*)xmalloc(sizeof(freerdp_mutex_t));
mutex = xnew(freerdp_mutex_t);
#if defined _WIN32
*mutex = CreateMutex(NULL, FALSE, NULL);

View File

@ -46,7 +46,7 @@ freerdp_sem freerdp_sem_new(int iv)
{
freerdp_sem_t* sem;
sem = (freerdp_sem_t*)xmalloc(sizeof(freerdp_sem_t));
sem = xnew(freerdp_sem_t);
#if defined __APPLE__
semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, iv);

View File

@ -28,22 +28,17 @@ STREAM* stream_new(int size)
{
STREAM* stream;
stream = (STREAM*)xmalloc(sizeof(STREAM));
stream = xnew(STREAM);
if (stream != NULL)
{
if (size != 0)
{
size = size > 0 ? size : 0x400;
stream->data = (uint8 *) xmalloc(size);
stream->data = (uint8*)xmalloc(size);
stream->p = stream->data;
stream->size = size;
}
else
{
/* empty stream */
memset(stream, 0, sizeof(STREAM));
}
}
return stream;
@ -64,6 +59,6 @@ void stream_extend(STREAM* stream)
pos = stream_get_pos(stream);
stream->size <<= 1;
stream->data = (uint8 *) realloc(stream->data, stream->size);
stream->data = (uint8*)xrealloc(stream->data, stream->size);
stream_set_pos(stream, pos);
}

View File

@ -386,11 +386,10 @@ void svc_plugin_init(rdpSvcPlugin* plugin, CHANNEL_ENTRY_POINTS* pEntryPoints)
memcpy(&plugin->channel_entry_points, pEntryPoints, pEntryPoints->cbSize);
plugin->priv = (rdpSvcPluginPrivate*)xmalloc(sizeof(rdpSvcPluginPrivate));
memset(plugin->priv, 0, sizeof(rdpSvcPluginPrivate));
plugin->priv = xnew(rdpSvcPluginPrivate);
/* Add it to the global list */
list = (rdpSvcPluginList*)xmalloc(sizeof(rdpSvcPluginList));
list = xnew(rdpSvcPluginList);
list->plugin = plugin;
freerdp_mutex_lock(g_mutex);

View File

@ -137,8 +137,7 @@ void freerdp_uniconv_uppercase(UNICONV *uniconv, char *wstr, int length)
UNICONV* freerdp_uniconv_new()
{
UNICONV *uniconv = xmalloc(sizeof(UNICONV));
memset(uniconv, '\0', sizeof(UNICONV));
UNICONV *uniconv = xnew(UNICONV);
#ifdef HAVE_ICONV
uniconv->iconv = 1;

View File

@ -42,7 +42,7 @@ wait_obj_new(void)
{
struct wait_obj* obj;
obj = (struct wait_obj*)xmalloc(sizeof(struct wait_obj));
obj = xnew(struct wait_obj);
#ifdef _WIN32
obj->event = CreateEvent(NULL, TRUE, FALSE, NULL);