Skip to contentSkip to conversation

nouveau: add nouveau_resource_destroy

PATCH In review Marcin Slusarz 3 participants 4 messages Jan 12, 2010 – Jan 22, 2010 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 nouveau: add nouveau_resource_destroy

From: Marcin Slusarz <[email protected]>
Subject: [libdrm PATCH] nouveau: add nouveau_resource_destroy

---
 nouveau/nouveau_resource.c |    9 +++++++++
 nouveau/nouveau_resource.h |    3 +++
 2 files changed, 12 insertions(+), 0 deletions(-)
nouveau/nouveau_resource.c +9 -0
index 6bef756..7acaf7d 100644
@@ -41,6 +41,15 @@ nouveau_resource_init(struct nouveau_resource **heap,
 	return 0;
 }
 
+void
+nouveau_resource_destroy(struct nouveau_resource **heap)
+{
+	if (!*heap)
+		return;
+	free(*heap);
+	*heap = NULL;
+}
+
 int
 nouveau_resource_alloc(struct nouveau_resource *heap, unsigned size, void *priv,
 		       struct nouveau_resource **res)
nouveau/nouveau_resource.h +3 -0
index 988d246..b760dfb 100644
@@ -38,6 +38,9 @@ int
 nouveau_resource_init(struct nouveau_resource **heap, unsigned start,
 		      unsigned size);
 
+void
+nouveau_resource_destroy(struct nouveau_resource **heap);
+
 int
 nouveau_resource_alloc(struct nouveau_resource *heap, unsigned size, void *priv,
 		       struct nouveau_resource **);
Signature · 1 line
1.6.6.rc3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Is everyone ok with this api addition (naming ok?)?

Quoted 50 lines · Marcin Slusarz

From: Marcin Slusarz <[email protected]>
Subject: [libdrm PATCH] nouveau: add nouveau_resource_destroy

---
 nouveau/nouveau_resource.c |    9 +++++++++
 nouveau/nouveau_resource.h |    3 +++

 2 files changed, 12 insertions(+), 0 deletions(-)
nouveau/nouveau_resource.c +9 -0
index 6bef756..7acaf7d 100644
@@ -41,6 +41,15 @@ nouveau_resource_init(struct nouveau_resource **heap,
        return 0;
  }
 
+void
+nouveau_resource_destroy(struct nouveau_resource **heap)
+{
+       if (!*heap)
+               return;
+       free(*heap);
+       *heap = NULL;
+}
+

 int
 nouveau_resource_alloc(struct nouveau_resource *heap, unsigned size, void *priv, struct nouveau_resource **res)

nouveau/nouveau_resource.h +3 -0
index 988d246..b760dfb 100644
@@ -38,6 +38,9 @@ int
  nouveau_resource_init(struct nouveau_resource **heap, unsigned start,
                      unsigned size);
 
+void
+nouveau_resource_destroy(struct nouveau_resource **heap);
+

 int
 nouveau_resource_alloc(struct nouveau_resource *heap, unsigned size, void *priv, struct nouveau_resource **);
--
1.6.6.rc3

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 6d4bc9fc1001141502l78f40a00n1074cdd4bf00a815-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 1 line · Maarten Maathuis

Is everyone ok with this api addition (naming ok?)?

I guess they are...

... Or is there any issue with this patch I'm not aware of?

Marcin

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 11 lines · Marcin Slusarz
Quoted 2 lines · Maarten Maathuis

Is everyone ok with this api addition (naming ok?)?

I guess they are...

... Or is there any issue with this patch I'm not aware of?

Marcin

In principle I guess we could also make nouveau_resource_free FREE the resource if (!next && !prev && !in_use), but I prefer the extra function.

Also, resource_destroy could iterate through all resources still linked with it and FREE them too, but that would probably not be necessary since all alloc'd ones should already have been released (but would produce a deserved segfault otherwise, if they're still used).

If no one speaks in favour of changing anything though, let's push this as is (?) ...

Christoph

Quoted 5 lines

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau