Skip to content

Commit

Permalink
misc: move structures away from pp_resource.h
Browse files Browse the repository at this point in the history
  • Loading branch information
i-rinat committed Dec 14, 2017
1 parent 4a29ab5 commit 79bbfa4
Show file tree
Hide file tree
Showing 75 changed files with 707 additions and 575 deletions.
6 changes: 5 additions & 1 deletion src/async_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "async_network.h"
#include <glib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
Expand All @@ -42,7 +44,9 @@
#include "trace.h"
#include "config.h"
#include "ppb_message_loop.h"

#include "ppb_tcp_socket.h"
#include "ppb_udp_socket.h"
#include "ppb_host_resolver.h"

static struct event_base *event_b = NULL;
static struct evdns_base *evdns_b = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <ppapi/c/pp_errors.h>
#include "ppb_var.h"
#include "trace.h"
#include "ppb_image_data.h"
#include <pango/pangocairo.h>


struct PP_Var
Expand Down
5 changes: 5 additions & 0 deletions src/glx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#define GLX_GLXEXT_LEGACY // prevent inclusion of glxext.h

#include <GL/glx.h>
2 changes: 2 additions & 0 deletions src/main_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@

#include "main_thread.h"
#include "ppb_message_loop.h"
#include "ppb_instance.h"
#include "pp_resource.h"
#include <pthread.h>
#include "trace.h"
#include "utils.h"


static
Expand Down
1 change: 1 addition & 0 deletions src/n2p_proxy_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "ppb_var.h"
#include "ppb_message_loop.h"
#include <ppapi/c/pp_errors.h>
#include "utils.h"


struct has_property_param_s {
Expand Down
3 changes: 3 additions & 0 deletions src/np_entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#include "ppb_core.h"
#include "gtk_wrapper.h"
#include "np_asynccall.h"
#include "ppb_instance.h"
#include <unistd.h>
#include "utils.h"


static void *module_dl_handler;
Expand Down
7 changes: 7 additions & 0 deletions src/np_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,21 @@
#include "ppb_var.h"
#include "ppb_core.h"
#include "ppb_cursor_control.h"
#include "ppb_instance.h"
#include "ppb_graphics2d.h"
#include "ppb_graphics3d.h"
#include "ppb_message_loop.h"
#include "ppb_flash_fullscreen.h"
#include "ppb_url_util.h"
#include "ppb_view.h"
#include "header_parser.h"
#include "keycodeconvert.h"
#include "eintr_retry.h"
#include "compat.h"
#include "utils.h"
#include "x11_event_thread.h"
#include <pango/pangocairo.h>
#include <unistd.h>


int16_t
Expand Down
1 change: 1 addition & 0 deletions src/p2n_proxy_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "ppb_core.h"
#include "ppb_message_loop.h"
#include "n2p_proxy_class.h"
#include "utils.h"


NPObject *
Expand Down
5 changes: 5 additions & 0 deletions src/p2n_proxy_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

#include <npapi/npapi.h>
#include <npapi/npruntime.h>
#include <ppapi/c/pp_var.h>

struct np_proxy_object_s {
NPObject npobj;
struct PP_Var ppobj;
};

extern struct NPClass p2n_proxy_class;
10 changes: 7 additions & 3 deletions src/pp_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ static GHashTable *destructors_ht = NULL;
static int res_tbl_next = 0;
static pthread_mutex_t res_tbl_lock = PTHREAD_MUTEX_INITIALIZER;

struct pp_resource_generic_s {
COMMON_STRUCTURE_FIELDS
};

static
__attribute__((constructor))
void
Expand All @@ -51,7 +55,7 @@ constructor_pp_resource(void)
PP_Resource
pp_resource_allocate(enum pp_resource_type_e type, struct pp_instance_s *instance)
{
struct pp_resource_generic_s *res = g_slice_alloc0(sizeof(union pp_largest_u));
struct pp_resource_generic_s *res = g_slice_alloc0(LARGEST_RESOURCE_SIZE);
res->resource_type = type;
res->ref_cnt = 1;
pthread_mutex_init(&res->lock, NULL);
Expand All @@ -71,7 +75,7 @@ pp_resource_expunge(PP_Resource resource)
pthread_mutex_lock(&res_tbl_lock);
void *ptr = g_hash_table_lookup(res_tbl, GINT_TO_POINTER(resource));
if (ptr) {
g_slice_free(union pp_largest_u, ptr);
g_slice_free1(LARGEST_RESOURCE_SIZE, ptr);
g_hash_table_remove(res_tbl, GINT_TO_POINTER(resource));
}
pthread_mutex_unlock(&res_tbl_lock);
Expand Down Expand Up @@ -191,7 +195,7 @@ pp_resource_unref(PP_Resource resource)
trace_error("%s, no destructor for type %d\n", __func__, ptr->resource_type);

// finally, free memory occupied by resource
g_slice_free1(sizeof(union pp_largest_u), ptr);
g_slice_free1(LARGEST_RESOURCE_SIZE, ptr);
}

if (config.quirks.dump_resource_histogram) {
Expand Down
Loading

0 comments on commit 79bbfa4

Please sign in to comment.