[openib-general] [PATCH][kdapl] Small changes in dapl_hca_alloc/dapl_hca_free functions
Itamar Rabenstein
itamar at mellanox.co.il
Mon Jun 20 01:46:16 PDT 2005
Small changes in dapl_hca_alloc/dapl_hca_free function
Signed-off-by: Itamar Rabenstein <itamar at mellanox.co.il>
diff -Nurp -X dontdiff dat-provider_hash/dapl_hca_util.c dat-provider/dapl_hca_util.c
--- dat-provider_hash/dapl_hca_util.c Sun Jun 19 16:12:55 2005
+++ dat-provider/dapl_hca_util.c Sun Jun 19 16:30:07 2005
@@ -54,23 +54,18 @@
struct dapl_hca *dapl_hca_alloc(char *name, struct ib_device *device, u8 port)
{
struct dapl_hca *hca;
-
- hca = kmalloc(sizeof *hca, GFP_ATOMIC);
+ int malloc_size = sizeof *hca + strlen(name) + 1;
+
+ hca = kmalloc(malloc_size, GFP_ATOMIC);
if (hca) {
- memset(hca, 0, sizeof *hca);
-
+ memset(hca, 0, malloc_size);
spin_lock_init(&hca->lock);
INIT_LIST_HEAD(&hca->ia_list);
-
- hca->name = dapl_os_strdup(name);
+ hca->name = (char *)hca + sizeof *hca;
+ strcpy(hca->name, name);
hca->ib_hca_handle = device;
hca->port_num = port;
- if (hca->name == NULL) {
- kfree(hca);
- hca = NULL;
- }
}
-
return hca;
}
@@ -91,7 +86,6 @@ struct dapl_hca *dapl_hca_alloc(char *na
*/
void dapl_hca_free(struct dapl_hca *hca)
{
- kfree(hca->name);
kfree(hca);
}
diff -Nurp -X dontdiff dat-provider_hash/dapl_util.h dat-provider/dapl_util.h
--- dat-provider_hash/dapl_util.h Sun Jun 19 16:12:56 2005
+++ dat-provider/dapl_util.h Sun Jun 19 16:30:52 2005
@@ -121,18 +121,6 @@ static inline void *dapl_os_realloc(void
}
/*
- * String Functions
- */
-
-static inline char *dapl_os_strdup(const char *str)
-{
- char *ns = kmalloc(strlen(str) + 1, GFP_KERNEL);
- if (ns)
- strcpy(ns, str);
- return ns;
-}
-
-/*
* *printf format helper. We use the C string constant concatenation
* ability to define 64 bit formats, which unfortunatly are non standard
* in the C compiler world.
--
Itamar
More information about the general
mailing list